JQuery的导航菜单动画与WordPress页面列表
题
所以我使用jQuery显示弹出在我目前的站点菜单。在HTML是一个WordPress为你的WordPress类型wp_list_pages输出那里。为了你的非WordPress的类型,这意味着,WordPress会输出嵌套UL和李要素按照WordPress的页面架构。底线,我想jQuery代码是WordPress的兼容,所以如果我更改页面,代码会处理这个问题。
我想要的代码是精简版,但以下是有点janky。任何更好的想法?另外,我想弹出菜单只出现在鼠标一直徘徊在UI元素为1000毫秒(1秒)之后,而不是其他。想法?
jQuery(document).ready(function() {
jQuery.fn.pauseit = function(duration) {
jQuery(this).animate({ dummy: 1 }, duration);
return this;
};
});
jQuery(document).ready(function() {
jQuery("div#access li.page_item ul").css({display: "none"}); // Opera Fix
jQuery("div#access li.page_item").hover(
function(){
jQuery(this).find('ul:first').pauseit(1000).css({/*visibility: "visible",display: "none"*/}).fadeIn('fast');
},
function(){
jQuery(this).find('ul:first').css({/*visibility: "hidden",*/}).fadeOut('fast');
}
);
});
解决方案
因此,我发现hoverIntent在 http://cherne.net/brian/resources/ jquery.hoverIntent.html 。这解决了我的问题。
不隶属于 StackOverflow