Home  >  Article  >  Web Front-end  >  jquery阻止冒泡事件使用模拟事件_jquery

jquery阻止冒泡事件使用模拟事件_jquery

WBOY
WBOYOriginal
2016-05-16 17:23:25965browse
复制代码 代码如下:



单击显示隐藏内容

这里是隐藏内容



当点击span的时候 div 和 body 的事件全部触发了。要阻止这种发生
$("span").bind("click", function(e){
$(".message").show();
e.stopPropagation();//完成事件清除动作
});

模拟事件 trigger
复制代码 代码如下:

$(".content").bind("myclick", function(event,message1,message2){
$("#test").append(message1+messages2);
});
$("#btn").trigger("myclick",["我的事件","触发了"]);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn