본문 바로가기

개발하자/자바스크립트

className 바꾸기

<html>
 <head>
 <style type="text/css">
 td { border : 5px solid navy; }
 .s1 { border-style:dotted; }
 </style>
 <script>
 window.onload=function(){
 t1.onclick=function(){
  this.className="s1";
 }
 t2.onclick=function(){
  this.className="s1"; //클래스 이름을 s1로 바꾼다. 그러므로 border속성값이 바뀐다.
 }
 }
 </script>
 </head>
 <body>
 <table>
 <tr>
 <td id=t1>aa</td>
 <td id=t2>bb</td>
 </tr>
 </table>
 </body>
</html>

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

과제1)토글기능 구현하기  (0) 2015.02.28
css바꾸기 확장성있는 코드  (0) 2015.02.28
과제!!깔끔하게 바꾸기 ing  (0) 2015.02.28
줄삭제 숫자 감소  (0) 2015.02.28
줄추가하기  (0) 2015.02.28