按照教程,我使用 JQuery 创建了一个简单的下拉菜单。链接: http ://wabism.com/development/jquerydropdown/
它的 jQuery 代码是这样的:
$('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();
});
});
下拉菜单工作正常,有 1 个错误。如果您快速滚动和退出菜单项 3 或 4 次,它会执行所有 3 或 4 个 slidetoggle() 。我怎样才能克服这个问题?