Working from CrazyJugglerDrummer's try, you'd want to hide and then cycle the a
s, not the img
s. Otherwise you'll be looking for next('img')
where it doesn't exist.
update Seems like it's a mix of CSS and js. I have it working now, like so:
<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 have to make sure your anchors and images are displayed block, and that the absolute position is set on your anchor. Also you need to further specify the :first-child
so as not to fade the image.
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>