简体   繁体   English

将查询滑块首先更改为默认幻灯片

[英]Change query slider first Slide as Default slide

Demo 01 演示01

In Demo 01 when I click #one, the first slide appears. 在演示01中,当我单击#one时,将显示第一张幻灯片。 But I need, the first slide already in the page, before click #one. 但是,我需要页面上已有的第一张幻灯片,然后单击#one。 the first slide must be the default slide of the slider. 第一张幻灯片必须是滑块的默认幻灯片。

How to change this code? 如何更改此代码?

Can u help with this. 你能帮忙吗

$(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 });
    });

});

Try this 尝试这个

$("li a:first").trigger("click");

after the click event click事件后

http://jsfiddle.net/fQs8N/3/ http://jsfiddle.net/fQs8N/3/

Or if you want to avoid animation for first appearance try this 或者,如果您想避免首次出现动画,请尝试此操作

$('.content:first').css('left', '0px');

before click or anywhere 点击之前或任何地方

http://jsfiddle.net/fQs8N/4/ http://jsfiddle.net/fQs8N/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM