我有一个鼠标悬停和移出的设置,用于列表项如下:
$("#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
});
});
我希望能在有人进入网站或页面加载时自动触发“.current-menu-item a”上的悬停效果。
目前,我使用
$(".current-menu-item a").trigger('hover');
,但它不起作用。请帮忙?