实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Related Elements Example</title>
5
    <script type="text/javascript" src="/upload/files/201702/EventUtil.js"></script>
6
</head>
7
<body>
8
    <div id="myDiv" style="background-color:red;height:100px;width:100px">Move the mouse from here to the white</div>
9
    <script type="text/javascript">
10
        var div = document.getElementById("myDiv");
11
        EventUtil.addHandler(div, "mouseout", function(event){
12
            event = EventUtil.getEvent(event);
13
            var target = EventUtil.getTarget(event);
14
            var relatedTarget = EventUtil.getRelatedTarget(event);
15
            alert("Moused out of " + target.tagName + " to " + relatedTarget.tagName);        
16
        }); 
17
18
    </script>
19
</body>
20
</html>
21