Javascript 使用stopPropagation时父DIV上发生的jQuery click事件

Javascript 使用stopPropagation时父DIV上发生的jQuery click事件,javascript,jquery,html,Javascript,Jquery,Html,jQuery(文档).ready(函数(){ //添加标题侦听器 //注册侦听器 jQuery(“.top nav login links.exchange signup”)。单击(headerObject.toggleLightBoxSignup.bind(headerObject)); //登录侦听器 jQuery(“.top nav login links.exchange login”)。单击(headerObject.toggleLightBoxLogin.bind(headerObj


jQuery(文档).ready(函数(){
//添加标题侦听器
//注册侦听器
jQuery(“.top nav login links.exchange signup”)。单击(headerObject.toggleLightBoxSignup.bind(headerObject));
//登录侦听器
jQuery(“.top nav login links.exchange login”)。单击(headerObject.toggleLightBoxLogin.bind(headerObject));
//Lightbox关闭侦听器
jQuery(“i.close-lightbox,div.light-box-parent”)。单击(函数(e){
e、 停止传播();
if(jQuery(this.attr(“data rel”)=“signUpVisible”){
headerObject.toggleLightBoxSignup();
}else if(jQuery(this).attr(“数据相关”)=“loginVisible”){
toggleLightBoxLogin();
}
});
});
变量头对象={
isLoginLightBoxVisible:false,
isSignupLightBoxVisible:false,
Iscookesbannervisible:没错,
showServicesDropdown:false,
isMobileMenuVisible:错误,
layoutElement:document.querySelector(“#布局”),
toggleLightBoxLogin:function(){
jQuery(“#loginVisible”).toggle();
},
toggleLightBoxSignup:function(){
jQuery(“#signUpVisible”).toggle();
},
toggleMobileMenu:function(){
如果(!this.isMobileMenuVisible){
this.layoutElement.classList.add(“活动”);
}否则{
this.layoutElement.classList.remove(“活动”);
}
this.isMobileMenuVisible=!this.isMobileMenuVisible;
},
closeCookiesBanner:function(){
this.iscookesbannervisible=false;
//localStorage.setItem('this.iscookesbannervisible','false');
},
onMenuItemClick:function(){
if((窗口中的“ontouchstart”)| |窗口[“DocumentTouch”]&&DocumentTouch的文档实例){
event.preventDefault();
event.stopPropagation();
}
}
};
登录 测试 蓝侠集团新成员?加入人群
试着用函数代替stopPropagation

你能创造一个上述情况吗?事件是否绑定/触发?你不能提供简单的代码来复制你的问题吗?不要直接使用click事件,而是根据你的jquery插件使用“jquery on”或“jquery live”。它基本上会为你处理的。@JeevaJsb这有什么不同?为什么OP需要委派事件?仅供参考
live()已经死了
它不应该死吗
。stopImmediatePropagation()