gpt4 book ai didi

javascript - 首先将查询 slider 更改为默认幻灯片

转载 作者:行者123 更新时间:2023-11-30 05:39:53 25 4
gpt4 key购买 nike

Demo 01

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

如何更改此代码?

你能帮忙吗。

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

点击事件之后

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

或者如果你想避免第一次出现动画,试试这个

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

点击前或任何地方

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

关于javascript - 首先将查询 slider 更改为默认幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21455902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com