개발하자/자바스크립트
버튼색변경
i구야
2015. 2. 5. 12:36
<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>