I am using one of snook.ca script for simple slideshow. Here it is in a nutshell:
<div class="fadein">
<img src="banner1.jpg" width="645" height="307"/>
<img src="banner2.jpg" width="645" height="307"/>
<img src="banner3.jpg" width="645" height="307"/>
</div>
<script>
$(function(){
$('.fadein img:gt(0)').hide();
setInterval(function(){$('.fadein :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');}, 4000);
});
</script>
Now I have tried to make these images clickable at while in slideshow. So my markup will be something like:
<div class="fadein">
<a href="yahoo.com"><img src="banner1.jpg" bwidth="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>
How do I achieve this functionality without making the script too complicated. Please note that <img/> tags are provided to me and I have no control over it.
Working from CrazyJugglerDrummer‘s try, you’d want to hide and then cycle the
as, not theimgs. Otherwise you’ll be looking fornext('img')where it doesn’t exist.update Seems like it’s a mix of CSS and js. I have it working now, like so:
with CSS
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-childso 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.