搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
jQuery 教程
jQuery 基础教程
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>jQuery mouseenter mouseleave click事件示例 - 基础教程(div.cn)</title> <head> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div").on("mouseenter mouseleave click", function(){ $(this).text(Math.random()); }); }); </script> </head> <body> <div style="padding:20px 10px; border:1px solid; user-select:none;">将鼠标指针悬停在此DIV上。</div> <p>上面的DIV将在3个不同的事件上显示随机数:</p> <ol> <li>mouseenter</li> <li>mouseleave</li> <li>click</li> </ol> </body> </html>
运行结果