尝试多次滚动悬停在链接上,这就是触发重复动画的原因。
查询//
// Wait for the page and all the DOM to be fully loaded
$('body').ready(function() {
// Add the 'hover' event listener to our drop down class
$('.dropdown').hover(function() {
// When the event is triggered, grab the current element 'this' and
// find it's children '.sub_navigation' and display/hide them
$(this).find('.sub_navigation').slideToggle();
});
});
HTML//
<ul id="navigation">
<li class="dropdown"><a href="#">Dropdown</a>
<ul class="sub_navigation">
<li><a href="#">Sub Navigation 1</a></li>
<li><a href="#">Sub Navigation 2</a></li>
<li><a href="#">Sub Navigation 3</a></li>
</ul>
</li>
<li class="dropdown"><a href="#">Dropdown 2</a>
<ul class="sub_navigation">
<li><a href="#">Sub Navigation 1</a></li>
<li><a href="#">Sub Navigation 2</a></li>
<li><a href="#">Sub Navigation 3</a></li>
</ul>
</li>