js广告轮询效果

        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>


你可能感兴趣的:(js)