如果已经打开,如何阻止这个jquery动画打开


How to stop this jquery animate from opening if already open?

我在一个菜单中有7个项目,使用鼠标悬停通过jquery向下设置动画。我的问题是,如果下拉菜单已经打开,我如何停止动画?:

jQuery('.navbar-inverse .navbar-nav>li:nth-child(1)>a').mouseover(function(){
jQuery('.navbar>li:nth-child(1)>.dropdown-menu-custom').animate({height: "toggle"}, 500, function(){});

我知道我需要一个if语句,但不确定该放什么?感谢您的帮助,

只需在每个项目打开时向其添加一个类.active,如果不是,则在触发mouseover()事件时,您可以检查它是否为"active",如果为true,则停止脚本,否则执行动画。

希望这能有所帮助。