마우스 오버 시 이전에 오버됐던 객체를 리턴한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
<div onmouseover="moouseOverHandler(event)">
    <div id="red" style="width:100px; height:100px; background:red"></div>
    <div id="blue" style="width:100px; height:100px; background:blue"></div>
    <div id="black" style="width:100px; height:100px; background:black"></div>
</div>
 
<div id="msg"></div>
 
<script>
    function moouseOverHandler(e){
        document.getElementById("msg").innerHTML = e.fromElement.getAttribute("id");    // IE: fromElement, 표준: relatedTarget
    }
</script>

+ Recent posts