相关元素:鼠标指针从一个元素的边界之内移动到另一个元素的边界之内

2017-06-19 11:55:00
admin
原创
463
<!DOCTYPE html>
<html>
<head>
    <title>Related Elements Example</title>
    <script type="text/javascript" src="http://code.ybao.org/demo/js/EventUtil.js"></script>
</head>
<body>
    <div id="myDiv" style="background-color:red;height:100px;width:100px">Move the mouse from here to the white</div>
    <script type="text/javascript">
        var div = document.getElementById("myDiv");
        EventUtil.addHandler(div, "mouseout", function(event){
            event = EventUtil.getEvent(event);
            var target = EventUtil.getTarget(event);
            var relatedTarget = EventUtil.getRelatedTarget(event);
            alert("Moused out of " + target.tagName + " to " + relatedTarget.tagName);        
        }); 

    </script>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络