Javascript 将查询滑块第一张幻灯片更改为默认幻灯片

Javascript 将查询滑块第一张幻灯片更改为默认幻灯片,javascript,jquery,Javascript,Jquery,在演示01中,当我单击#one时,第一张幻灯片出现。但我需要的是,在单击“一”之前,页面中已经有了第一张幻灯片。第一张幻灯片必须是滑块的默认幻灯片 如何更改此代码 你能帮忙吗 $(function () { // get the width of the first content box // add a bit of extra so we end up with "-350px" var contentWidth = '-' + ($('.content').wi

在演示01中,当我单击#one时,第一张幻灯片出现。但我需要的是,在单击“一”之前,页面中已经有了第一张幻灯片。第一张幻灯片必须是滑块的默认幻灯片

如何更改此代码

你能帮忙吗

$(function () {

    // get the width of the first content box
    // add a bit of extra so we end up with "-350px"
    var contentWidth = '-' + ($('.content').width() + 50) + 'px';

    // reposition the content here in case javascript is disabled
    $('.content').css({
        position: 'absolute',
        left: contentWidth
    });

    $("li a").click(function () {
        event.preventDefault();
        var $blockID = $( $(this).attr('href') );
        // if the content is already showing, don't do anything
        if ($blockID.hasClass('visible')) { return; }
        // hide any visible content
        $('.content.visible')
            .removeClass('visible')
            // move the old content past the current window width, then reset it's position
            .animate({
                left: '-' + $(window).width()
            }, function () {
                // Remove left setting after the animation completes
                $(this).css('left', contentWidth);
            });
        $blockID
            .addClass('visible')
            .animate({ left: 0 });
    });

});
试试这个

$("li a:first").trigger("click");
事件之后,单击
事件

或者,如果要避免第一次出现动画,请尝试以下方法

$('.content:first').css('left', '0px');
在单击或单击任何位置之前