如何在下拉子菜单处于活动状态时停止向上滑动。单击子菜单时,下拉菜单会向上滑动,而不是我需要停止向上滑动并保持子菜单的活动状态。有人可以帮我解决这个问题吗?这是用于此的 HTML 和 js 代码
<div class="sidebar-menu">
<ul>
<li <?php if($this->uri->segment(1)=="cc"){echo 'class="active"';}?> >
<a href="#">Create Contract</a></li>
<li class="sidebar-dropdown">
<a href="#">
Create Master Data
</a>
<div class="sidebar-submenu">
<ul id="submenu" class=" treeview-menu nav navbar-nav side-nav">
<li>
<a href="#" <?php if($this->uri->segment(2)=="city"){echo 'class="active"';}?> >City</a>
</li>
<li>
<a href="#" <?php if($this->uri->segment(2)=="business"){echo 'class="active"';}?> >Line of business</a>
</li>
</ul>
</div>
</li>
$(".sidebar-dropdown > a").click(function(e) {
$(".sidebar-submenu").slideUp(200);
if (
$(this)
.parent()
.hasClass("active")
) {
$(".sidebar-dropdown").removeClass("active");
$(this)
.parent()
.removeClass("active");
} else {
$(".sidebar-dropdown").addClass("active");
$(this)
.next(".sidebar-submenu")
.slideDown(200);
$(this)
.parent()
.addClass("active");
}
});
相关分类