您的位置:首页 > Web前端 > JavaScript

js广告轮询效果

2013-07-13 20:08 190 查看
var intervalTime = 5000;
var showIndex = 0;
var imageLength=0;
$(window).load(function () {
var height = $("#swfLoad").height();
var width = $("#swfLoad").width();
$("#swfLoad img").each(function (index) {
$(this).height(height).width(width).css("position", "absolute").css("top", 0).css("left", 0);
if (index == "0") {
$(this).css("visibility", "visible");
}
else {
//$(this).css("visibility", "hidden");
}
imageLength++;
});
setInterval("change();", intervalTime);
});
function change() {
$("#swfLoad img").eq(showIndex).fadeOut(1000);
showIndex++;
if (showIndex >= imageLength) {
showIndex = 0;
}
$("#swfLoad img").eq(showIndex).fadeIn(1000);
}
</script>
<div id="swfLoad" style="position:relative;visibility:visible; width:700px; height:280px;">
<img src="../../Images/1355799066906_000.jpg" alt="" />
<img src="../../Images/1369276714638_000.jpg" alt="" />
<img src="../../Images/1369277578381_000.jpg" alt="" />
<img src="../../Images/1371957347577_000.jpg" alt="" />
</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: