Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用e.preventDefault()、e.StopperPropagation()、停止内部锚定以单击的超大菜单滑动和向下滑动_Jquery_Preventdefault_Stoppropagation - Fatal编程技术网

Jquery 使用e.preventDefault()、e.StopperPropagation()、停止内部锚定以单击的超大菜单滑动和向下滑动

Jquery 使用e.preventDefault()、e.StopperPropagation()、停止内部锚定以单击的超大菜单滑动和向下滑动,jquery,preventdefault,stoppropagation,Jquery,Preventdefault,Stoppropagation,这是一个超大菜单的设计,我希望它能像手风琴一样工作,但问题是它的内部锚,现在不能点击 $(文档).ready(函数(){ $(“.megaMenu>li”)。单击(函数(e){ 如果(例如,目标!==此){ 返回false; }否则{ $(“.megaMenu>li”).not(this.find(“.subMenu:first”).slideUp(); $(this.find(“.subMenu:first”).slideToggle(); e、 预防默认值(); e、 停止传播(); }

这是一个超大菜单的设计,我希望它能像手风琴一样工作,但问题是它的内部锚,现在不能点击

$(文档).ready(函数(){
$(“.megaMenu>li”)。单击(函数(e){
如果(例如,目标!==此){
返回false;
}否则{
$(“.megaMenu>li”).not(this.find(“.subMenu:first”).slideUp();
$(this.find(“.subMenu:first”).slideToggle();
e、 预防默认值();
e、 停止传播();
}
});
$(“.子菜单>li”)。单击(函数(e){
如果(例如,目标!==此){
返回false;
}否则{
$(“.subMenu>li”).not(this.find(“.subMenu:first”).slideUp();
$(this.find(“.subMenu:first”).slideToggle();
e、 预防默认值();
e、 停止传播();
}
});
});
.megaMenu{
显示器:flex;
弯曲方向:立柱;
}
.megaMenu>li{
利润率:10px0;
填充:10px;
背景色:#eaeaea;
光标:指针;
}
.megaMenu.子菜单{
显示:无;
}
.megaMenu.li子菜单{
利润率:10px0;
位置:相对位置;
}
.megaMenu.子菜单li:之后{
位置:绝对位置;
右:0;
排名:0;
内容:“>”;
}
.megaMenu.子菜单li a{
显示:块;
宽度:80%;
背景色:#ddd;
}


你应该像这样编辑你的js。 那是你想要的吗

$(文档).ready(函数(){
$(“.megaMenu>li”)。单击(函数(e){
如果(e.target==此){
$(“.megaMenu>li”).not(this.find(“.subMenu:first”).slideUp();
$(this.find(“.subMenu:first”).slideToggle();
}
});
$(“.子菜单>li”)。单击(函数(e){
如果(e.target==此){
$(“.subMenu>li”).not(this.find(“.subMenu:first”).slideUp();
$(this.find(“.subMenu:first”).slideToggle();
}
});
});
.megaMenu{
显示器:flex;
弯曲方向:立柱;
}
.megaMenu>li{
利润率:10px0;
填充:10px;
背景色:#eaeaea;
光标:指针;
}
.megaMenu.子菜单{
显示:无;
}
.megaMenu.li子菜单{
利润率:10px0;
位置:相对位置;
}
.megaMenu.子菜单li:之后{
位置:绝对位置;
右:0;
排名:0;
内容:“>”;
}
.megaMenu.子菜单li a{
显示:块;
宽度:80%;
背景色:#ddd;
}

    • <