简单教程
提交运行
代码编辑器:
<!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").mouseover(function(){ $(".over span").text(x+=1); }); $("div.enter").mouseenter(function(){ $(".enter span").text(y+=1); }); }); </script> <p>mouseover 事件在鼠标移动到选取的元素及其子元素上时触发 </p> <p>mouseenter 事件只在鼠标移动到选取的元素上时触发</p> <div> <div class="over" style="background-color:lightgray;width:49%;float:left"> <h3 style="background-color:white;">Mouseover 事件触发: <span>0</span></h3> </div> <div class="enter" style="background-color:lightgray;width:49%;float:right"> <h3 style="background-color:white;">Mouseenter 事件触发: <span>0</span></h3> </div> <div style="clear:both"></div> </div> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: