상세 컨텐츠

본문 제목

스크립트 innerHTML을 이용해 구구단 뽑기

관리X 과거글

by 까먹기전에 2015. 2. 10. 15:08

본문

반응형

<html>

 <head>

 <style type="text/css">

.a{

align : center

}

div{

    overflow:auto;

border : dashed blue;

}

 #con { background:gray; width:100px; height:240px; }

.zzaz{

border : dashed 2px green;

background:brown;

font-family:"궁서";

Color:white


}

.hol{

border : dotted 2px red ;

background:yellow;

font-family:"돋움";

Color:#99004C


}


 </style>

 <script>

 function printGugudan(num){

var s = "";


s+="<table>";


for(i=1; i<10; i++){

s+="<tr>"

if(i%2==0){

s+="<td class=zzaz width=1% height=1%>"

}

else{

s+="<td class=hol width=1% height=1%>"

}

s+= num + "*" + i + "=" + num*i

s+="</td>"

}

s+="</table>";

con.innerHTML=s;

}

 </script>

 </head>

 <body>

 <input type="text" id="dan">

 <input type="button" value="구구단출력" onclick="printGugudan(dan.value)">

 <div id="con"></div>

 </body>

</html>





아이쁘다 알록달록하네


관련글 더보기