<html>
<head>
<style type="text/css">
input{background:orange;E}
</style>
<script>
function a(b){
if(b==1)
b1.style.background="red" //style 안에있는거 데려올때 style적어줘야함
else
b2.style.background="blue"
}
</script>
</head>
<body>
<input type="button" value="aa" id="b1" onclick=a(1)>
<input type="button" value="bb" id="b2" onclick=a(2)>
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
배열사용 (0) | 2015.02.07 |
---|---|
주석 (0) | 2015.02.07 |
1~100까지 10X10칸만들기(5의 배수표시) (0) | 2015.02.05 |
html onclick 이벤트 (0) | 2015.02.05 |
rowspan,colspan (0) | 2015.02.05 |