我有一个随机的图片代码,但时间介绍不适用于代码
<script type="text/javascript">
//extending jQuery with ':random' selector, best put into separate plugin js file
jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
random: function(a, i, m, r) {
if (i == 0) {
jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
};
return i == jQuery.jQueryRandom;
}
});
//end :random extend
$ (Function () {
var next = function ()
{
. $ ('# Slideshow img') not (': random') hide ().
setInterval (function () {
$ ('# Slideshow img: visible') fadeOut ('slow').
. Siblings ('img: random'). FadeIn ('slow')
}, 10000);
}
next ();
});
</script>
那“10000”没有用。请帮帮我
答案 0 :(得分:1)
试试这个,
setInterval(function(){
randNum = getRandomInt(0, imgArray.length - 1);
nextBG = "url(" + imgArray[randNum] + ") no-repeat bottom center";
$('#slideshow img:first').attr("src", imgArray[randNum]);
},10000);