개발하자/자바스크립트
className 바꾸기
i구야
2015. 2. 28. 12:42
<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>