여러 객체를 하나의 이벤트로 처리하는방법??
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript">
<!--
function changeColor(hObj){
//var hObj = document.getElementById('h');
hObj.style.background='#996633';
}
function changeOutColor(hObj){
//var hObj = document.getElementById('h');
hObj.style.background='white';
}
//-->
</script>
</head>
<body>
<h1 onmouseover = "changeColor(this);" onmouseout = "changeOutColor(this)">Hello</h1>
<h1 onmouseover = "changeColor(this);" onmouseout = "changeOutColor(this)">Hello2</h1>
<h1 onmouseover = "changeColor(this);" onmouseout = "changeOutColor(this)">Hello2</h1>
</body>
</html>
//var hObj = document.getElementById('h');
이렇게 하나하나 지정해서 주지 말고
function changeColor(hObj)에서 () 안에 넘어오는걸 인수로 받아서
3개의 객체들을 한번에 이벤트처리를 할수 있는 것이다. 그럴러면 넘겨줄때
onmouseover = "changeColor(this);" onmouseout = "changeOutColor(this)
이런 식으로 this (즉 눌릴떄 '나' 라는걸 알게 하려고)를 주면 된다.