分享JS自动轮播代码
时间:2011-04-11 来源:flyhacker
var r_nmuber = 1;
function GetRandom(n){ r_nmuber=Math.floor(Math.random()*n+1); }
$(document).ready(function(){
var count=$(".r-2").length;
GetRandom(count-1);
var current = r_nmuber - 1;
$(".r-2").eq(current).fadeIn("slow");
function fad()
{
$(".r-2").eq(current).hide();
if(current == count-1){
current = 0;
}else{
current++;
}
$(".r-2").eq(current).fadeIn("slow");
}
setInterval(fad, 10000);
})
function GetRandom(n){ r_nmuber=Math.floor(Math.random()*n+1); }
$(document).ready(function(){
var count=$(".r-2").length;
GetRandom(count-1);
var current = r_nmuber - 1;
$(".r-2").eq(current).fadeIn("slow");
function fad()
{
$(".r-2").eq(current).hide();
if(current == count-1){
current = 0;
}else{
current++;
}
$(".r-2").eq(current).fadeIn("slow");
}
setInterval(fad, 10000);
})
相关阅读 更多 +