我有一个悬停鼠标mouseout设置如下列表项:
$("#main-nav li a").hover(function() {
$el = $(this);
leftPos = $el.position().left;
newWidth = $el.parent().width();
$magicNav.stop().animate({
left: leftPos,
width: newWidth
});
}, function() {
t1 = $(".current-menu-item a").position().left;
t2 = $(".current-menu-item a").parent().width();
$magicNav.stop().animate({
left: t1,
width: t2
});
});
Run Code Online (Sandbox Code Playgroud)
我想在有人进入网站或加载页面时自动触发".current-menu-item a"上的悬停.
目前,我使用$(".current-menu-item a").trigger('hover');它并不起作用.
救命?
用这个
$(document).ready(function(){
$(".current-menu-item a").mouseover();
});
Run Code Online (Sandbox Code Playgroud)
要么
$(window).load(function(){
$(".current-menu-item a").mouseover();
});
Run Code Online (Sandbox Code Playgroud)