When working with CrazyJugglerDrummer , try, you want to hide and then loop a s, not img s. Otherwise, you will look for next('img') where it does not exist.
update This seems to be a combination of CSS and js. Now I work like this:
<div class="fadein"> <a href="yahoo.com"><img src="banner1.jpg" width="645" height="307"/></a> <a href="google.com"><img src="banner2.jpg" width="645" height="307"/></a> <a href="live.com"><img src="banner3.jpg" width="645" height="307"/></a> </div> <script> $(function(){ $('.fadein a:gt(0)').hide(); setInterval(function(){$('.fadein a:first-child').fadeOut().next('a').fadeIn().end().appendTo('.fadein');}, 4000); }); </script>
with CSS
.fadein { position:relative; width:645px; height:307px; } .fadein a { position:absolute; left:0; top:0; display:block; text-decoration:none; } img { border:0; display:block; }
You must make sure that a block is displayed on your anchors and images, and that the absolute position is set at your anchor. You also need to specify :first-child so that the image does not disappear.
further update . Using 1.3.2 jQuery and XHTML Strict. Works in FF, IE6-8, Safari, Chrome, and Opera.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <style type="text/css"> .fadein { position:relative; width:645px; height:307px; } .fadein a { position:absolute; left:0; top:0; display:block; text-decoration:none; } img { border:0; display:block; } </style> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script> $(document).ready(function(){ $('.fadein a:gt(0)').hide(); setInterval(function(){$('.fadein a:first-child').fadeOut().next('a').fadeIn().end().appendTo('.fadein');}, 4000); }); </script> </head> <body> <div class="fadein"> <a href="yahoo.com"><img src="banner1.jpg" width="645" height="307" alt="1" /></a> <a href="google.com"><img src="banner2.jpg" width="645" height="307" alt="2" /></a> <a href="live.com"><img src="banner3.jpg" width="645" height="307" alt="3" /></a> </div> </body> </html>
source share