我正在开发一个通过 ajax 加载的大型下拉菜单。我想在菜单中添加悬停意图,但我无法找到一个将 .live() 与 hoverintent 结合的好例子。
我想将悬停延迟几秒钟,以便让其他菜单在崩溃时领先一步。
<script type="text/javascript">
$(document).ready(function(){
$('li.top-nav-links').live('mouseenter', function() {
$(this).find('a.top-nav-link-hover').addClass("top-nav-hover");
$(this).find('div').slideDown(300);
$(this).css('z-index', 9000 );
});
$('li.top-nav-links').live('mouseleave', function() {
$(this).find('div').slideUp(function() {
$(this).siblings('a.top-nav-hover').removeClass("top-nav-hover");
});
$(this).css('z-index', 8000 );
});
});
</script>
注意:基本上它是一个无序列表,显示其中隐藏的 div。z-index 将最新的悬停下拉列表重新排序到顶部