gpt4 book ai didi

jquery - Flexslider 动画后随机顺序

转载 作者:行者123 更新时间:2023-12-01 04:06:41 26 4
gpt4 key购买 nike

我正在尝试随机化 Flexslider 上的幻灯片顺序。随机选项仅允许您随机化加载顺序。我在这个的帮助下拼凑了下面的代码: Flexslider Start at a random slide and then continue loading sequentially

知道我做错了什么吗?

$(window).load(function() {
var randomthis = Math.floor((Math.random()* $('.flexslider li').length )+1);
$('.flexslider').flexslider({
after: function(slider) {
startAt: randomthis
},
});
});

最佳答案

FlexSlider 支持随机幻灯片。您可以使用以下代码

$(window).load(function() {
$('.flexslider').flexslider({
randomize: true
});
});

根据您的要求,您可以使用以下代码。

$(window).load(function() {
var randomthis = Math.floor((Math.random()* $('.flexslider li').length ));
$('.flexslider').flexslider({
after: function(slider) {
startAt: randomthis
},
});

// **CAUTION** the below code will remove ALL the setTimeouts
var highestTimeoutId = setTimeout(";");
for (var i = 0 ; i < highestTimeoutId ; i++) {
clearTimeout(i);
}

// This code will add a new setTimeout function for randomizing the
a = function(){
var newrandval = Math.floor((Math.random()* $('.flexslider li').length ));
while(randomthis == newrandval){
newrandval = Math.floor((Math.random()* $('.flexslider li').length ))
}
randomthis = newrandval;
$('.flexslider').flexslider(randomthis); setTimeout(a,3000)
}
a();
});

关于jquery - Flexslider 动画后随机顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26664030/

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