jQuery事件冒泡样例
2015-08-30 23:37
726 查看
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <script src="jquery-1.8.3.min.js"></script> <style> .oDiv { background: red; width: 200px; height: 200px; margin: 0 auto; } .iDiv { background: blue; width: 100px; height: 100px; } </style> <script> $(function(){ // alert(2) $(".oDiv").click(function(){ console.log("outerclick"); event.stopPropagation(); }); $(".iDiv").click(function(event){ console.log("innerclick"); event.stopPropagation(); }); $("body").click(function(){ console.log("bodyclick"); }); }); </script> </head> <body> <div class="oDiv">这是外层div <div class="iDiv">这是内层</div> </div> </body> </html>
相关文章推荐
- 浅析jQuery中常用的元素查找方法总结
- jquery文档处理
- jquery选择器(原创)<二>
- jquery几个常用的demo
- jquery的checkbox操作
- jQueryMobile的事件
- jQuery操作DOM元素
- JQuery的ready函数与JS的onload的区别
- jQueryMobile的组件之下拉菜单(selectMenu)
- 如何尽量避免引用jQuery
- 从html字符串中获取div内容---jquery
- jquery插件封装:弹出iframe模式框
- jQuery事件命名空间
- 【JavaScript】小样例-js仿jquery的表单验证
- Jquery对象的文档处理,CSS和事件
- jquery 获取 outerHtml 包含当前节点本身的代码
- PHP与jquery前后台交互的小程序
- jquery选择器(原创)
- jQueryMobile的组件之弹出窗(popup)
- jQueryMobile的组件之导航条(navbar)