简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8"> <link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <script> x=0; y=0; $(document).ready(function(){ $("div.over").mouseout(function(){ $(".over span").text(x+=1); }); $("div.enter").mouseleave(function(){ $(".enter span").text(y+=1); }); }); </script> <p>mouseout 事件在鼠标离开任意一个子元素及选的元素时触发</p> <p>mouseleave 事件只在鼠标离开选取的的元素时触发</p> <div> <div class="over" style="background-color:lightgray;padding:0px;width:50%;float:left"> <h3 style="background-color:white;">Mouseout 事件触发: <span>0</span></h3> </div> <div class="enter" style="background-color:lightgray;padding:0px;width:50%px;float:right"> <h3 style="background-color:white;">Mouseleave 事件触发: <span>0</span></h3> </div> <div style="clear:both"></div> </div> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: