본문 바로가기

개발하자/자바스크립트

테이블에 구구단출력

<html>
 <head>
 <style type="text/css">
 #con { background:#FAF4C0;
 width:200px;
 height:240px;
 border:3px dotted #FF5E00}
#jj { background:yellow;
 color:red;
 font-family:"궁서";
 border:2px double #ABF200;
 }

#hh { background:#F361DC;
 font-family:"궁서";
 border:2px dashed #FFEBFF;
 }

 </style>
 <script>

 function printGugudan(){
var aa="";
for(a=1;a<10;a++){
if(a%2==0){
aa+="<tr align=center>"+"<td id=jj +>"+dan.value+"X"+a+"="+dan.value*a+"<br>"+"</td>"+"</tr>";
}else{
aa+="<tr align=center>"+"<td id=hh width =1% height = 1%>"+dan.value+"X"+a+"="+dan.value*a+"<br>"+"</td>"+"</tr>";
}
}
con.innerHTML="<table>"+aa+"</table>";
 }
 </script>
 </head>
 <body>
 <input type="text" id="dan">
 <input type="button" value="구구단출력" onclick="printGugudan()">
 <div id="con"></div>
 </body>
</html>

'개발하자 > 자바스크립트' 카테고리의 다른 글

문자형에서 정수형으로 자료형 변환(parseInt)  (0) 2015.02.12
innerHTML  (0) 2015.02.10
input type  (0) 2015.02.10
top,blank,self  (0) 2015.02.10
프레임 나누기  (0) 2015.02.10