开发者社区 问答 正文

关于jquery页面加载时鼠标移动事件

如何在页面首次加载进来的时候也能触发鼠标移动的这个事件

    $(function(){
        $(".newsbox .tab span").hover(function(){
            $(this).addClass("cur").siblings().removeClass("cur");
            var index = $(".newsbox .tab span").index(this);
            $(".newsbox ul").eq(index).show().siblings().hide();
        })
    })

展开
收起
吴孟桥 2016-06-02 12:11:07 1986 分享 版权
1 条回答
写回答
取消 提交回答
  • trigger下

    $(function() {
            $(".newsbox .tab span").hover(function() {
                $(this).addClass("cur").siblings().removeClass("cur");
                var index = $(".newsbox .tab span").index(this);
                $(".newsbox ul").eq(index).show().siblings().hide();
            }).eq(0).trigger('mouseenter');
        })
    2019-07-17 19:24:35
    赞同 展开评论