Created
September 7, 2010 14:20
-
-
Save nu7hatch/568409 to your computer and use it in GitHub Desktop.
Simple banner rotator with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> | |
<link href="rotate.css" rel="stylesheet" type="text/css" /> | |
<script type="text/javascript" src="rotate.js"></script> | |
<script type="text/javascript"> | |
$(window).load(function() { | |
startRotator("#rotator"); | |
}) | |
</script> | |
</head> | |
<body> | |
<div id="rotator"> | |
<img height="54" src="http://profill.biz.pl/images/klienci/1.jpg" width="150" /> | |
<img height="55" src="http://profill.biz.pl/images/klienci/2.jpg" width="168" /> | |
<img height="69" src="http://profill.biz.pl/images/klienci/3.jpg" width="138" /> | |
<img height="52" src="http://profill.biz.pl/images/klienci/4.jpg" width="158" /> | |
<img height="114" src="http://profill.biz.pl/images/klienci/5.jpg" width="117" /> | |
<img height="46" src="http://profill.biz.pl/images/klienci/6.jpg" width="190" /> | |
<img height="58" src="http://profill.biz.pl/images/klienci/7.jpg" width="177" /> | |
<img height="79" src="http://profill.biz.pl/images/klienci/8.jpg" width="174" /> | |
<img height="53" src="http://profill.biz.pl/images/klienci/10.jpg" width="161" /> | |
<img height="85" src="http://profill.biz.pl/images/klienci/11.jpg" width="128" /> | |
<img height="46" src="http://profill.biz.pl/images/klienci/12.jpg" width="140" /> | |
<img height="77" src="http://profill.biz.pl/images/klienci/13.jpg" width="139" /> | |
<img height="49" src="http://profill.biz.pl/images/klienci/14.jpg" width="152" /> | |
<img height="53" src="http://profill.biz.pl/images/klienci/15.jpg" width="137" /> | |
<img height="47" src="http://profill.biz.pl/images/klienci/16.jpg" width="150" /> | |
<img height="40" src="http://profill.biz.pl/images/klienci/17.jpg" width="153" /> | |
<img height="144" src="http://profill.biz.pl/images/klienci/18.jpg" width="149" /> | |
<img height="56" src="http://profill.biz.pl/images/klienci/19.jpg" width="170" /> | |
<img height="81" src="http://profill.biz.pl/images/klienci/20.jpg" width="161" /> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rotator img { position: absolute; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rotateBanners(elem) { | |
var active = $(elem+" img.active"); | |
var next = active.next(); | |
if (next.length == 0) | |
next = $(elem+" img:first"); | |
active.removeClass("active").fadeOut(200); | |
next.addClass("active").fadeIn(200); | |
} | |
function prepareRotator(elem) { | |
$(elem+" img").fadeOut(0); | |
$(elem+" img:first").fadeIn(0).addClass("active"); | |
} | |
function startRotator(elem) { | |
prepareRotator(elem); | |
setInterval("rotateBanners('"+elem+"')", 2500); | |
} |
Dear admin
How do I add a destination to each image source?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dzieki panie dzieju. proste i skuteczne.