/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var count = 0, holder = '#rotatorSlides', sclass = '.rslide', inc = 4000; function rotate() { count++; // Create loop setTimeout(function() { rotate(); }, inc); // If this is the first iteration if (count == 1) { var first = $(sclass)[0]; var firstc = $(first).clone().appendTo(holder).siblings().hide(); $(first).remove(); return; } // Rotate Images var img = $(sclass)[0]; var clone = $(img).clone().appendTo(holder).fadeIn(800, function() { $(this).siblings().hide(); }); $(img).remove(); } // Usage Example // // CSS RULES // #rotatorSlides { // width: 589px; // height: 114px; // position: relative; // } // img.rslide { // position: absolute; // top: 0px; // left: 0px; // } // // HTML MARKUP // <div id="rotatorSlides"> // <img src="images/rslide-1.jpg" width="589" height="114" alt="" class="rslide"> // <img src="images/rslide-2.jpg" width="589" height="114" alt="" class="rslide"> // <img src="images/rslide-3.jpg" width="589" height="114" alt="" class="rslide"> // <img src="images/rslide-4.jpg" width="589" height="114" alt="" class="rslide"> // </div>