https://csjiabin.github.io/ hjb, csjiabin, csjiabin Blog, 黄佳滨的博客, huangjiabin, 黄佳滨, html, css, javascript, js, JavaScript, Node, node, nodejs, h5, html5, 小程序, vue

事件阻止

注意,只能是在bind-click事件中处理!在onClick事件中无法阻止冒泡的!

事件中
event.stopPropagation(); //阻止了事件冒泡,但不会阻击默认行为
event.preventDefault(); // 不阻击事件冒泡,但阻击默认行为
return false; //阻止了事件冒泡,也阻止了默认行为
return true和没有return是一个逻辑事件继续,即不阻击事件冒泡也不会阻击默认行为
这里return true是为了保证开发者可以在任何节点上进行事件绑定;(这个点没有想到什么情况需要阻止默认行为)

posted @ 2016-12-15 17:29  淡然丶blue  阅读(237)  评论(1编辑  收藏  举报
https://csjiabin.github.io/ hjb, csjiabin, csjiabin Blog, 黄佳滨的博客, huangjiabin, 黄佳滨, html, css, javascript, js, JavaScript, Node, node, nodejs, h5, html5, 小程序, vue