sol1)
<html>
<head>
<script>
function a(c){
c.style.background="red";
}
function b(c){
c.style.background="";
}
</script>
</head>
<body>
<input type="button" onmouseover="a(this)" onmouseout="b(this)">
</body>
</html>
sol2)
<html>
<head>
<script>
window.onload=function(){
btn.onmouseover=function(){
this.style.background="red";
}
btn.onmouseout=function(){
this.style.background="";
}
}
</script>
</script>
</head>
<body>
<input type="button" id=btn>
</body>
</html>
sol3)
<html>
<head>
<script>
window.onload=function(){
c.onmouseover=a;
c.onmouseout=b;
}
function a(){
this.style.background="red";
}
function b(){
this.style.background="";
}
</script>
</head>
<body>
<input type="button" id="c">
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
substring(n1[,n2]) (0) | 2015.02.14 |
---|---|
event.srcElement (이벤트가 발생한 곳의 주소값) (0) | 2015.02.14 |
원하는 객체의 값 변경(강아지 이름 변경 예제) (0) | 2015.02.14 |
원하는 객체의 값 변경(자동차 색상 예제) (0) | 2015.02.14 |
객체생성하기 (0) | 2015.02.14 |