小编Pre*_*ani的帖子

jQuery:自动触发悬停

我有一个悬停鼠标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');它并不起作用.

救命?

html css jquery

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

html ×1

jquery ×1