The jQuery cycle plugin is pretty freakin' awesome, but I couldn't figure out how to put a link behind each image. Sure there is a tutorial, but the images refused to show up no matter how much CSS tweaking I applied.
So I came up with a quick and dirty solution that uses jQuery to handle the click event for each image in the slideshow.
First the markup for the slideshow images:
<div id="slideshow">
<img src="'banner1.jpg" alt="" rel="/" />
<img src="'banner2.jpg" alt="" rel="/collections/skincare" />
<img src="'banner3.jpg" alt="" rel="/collections/men" />
<img src="'banner4.jpg" alt="" rel="/collections/men" />
<img src="'banner5.jpg" alt="" rel="/products/the-ultimate-guide-to-beauty-by-anjana-gosai" />
</div>
It is basically the same as what you normally use, but each image has an additional "rel" attribute with the location to link to.
Now the javascript:
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#slideshow').cycle({fx: 'fade', timeout:5000, speed:1000});
jQuery('#slideshow img').click(function (){
document.location.href = jQuery(this).attr('rel');
}).css('cursor', 'pointer');
});
</script>
I am adding a click handler to each <img> element in the slideshow div, and using whatever is specified in the rel attribute as the location to go to. Finally, I make the cursor a pointer for each image so the user knows it is click-able.
You can see it in action here.
Posted by: Erick Dovale | 2009.10.06 at 10:39 PM
Posted by: BBG | 2009.10.07 at 01:10 AM
Posted by: PepuaPC | 2010.01.04 at 08:35 PM
Posted by: Gercek Karakus | 2010.01.14 at 02:17 PM
Posted by: Justin | 2010.02.26 at 04:13 PM
Posted by: Mark | 2010.04.20 at 03:28 PM
Posted by: marcelo | 2010.09.02 at 05:01 PM
Posted by: Saudi Jobs | 2010.09.10 at 06:49 PM
Posted by: markov | 2011.01.29 at 01:26 AM
Posted by: Dan | 2011.05.03 at 12:13 PM
Posted by: guillaume | 2011.05.09 at 07:18 PM
Posted by: jack | 2011.05.16 at 05:50 PM
Posted by: Fer | 2011.05.26 at 12:09 PM
Posted by: Jorge | 2011.06.08 at 05:11 PM
Posted by: michael | 2011.06.29 at 09:03 PM
Posted by: tommy | 2011.07.19 at 10:28 AM
Posted by: Merry | 2011.08.31 at 11:55 AM
Posted by: jonathan | 2011.09.02 at 01:46 PM
Posted by: Sam Lowry | 2011.09.07 at 04:30 PM
Posted by: Gavin | 2011.09.07 at 04:41 PM
"+ "" + "
Posted by: Elizabeth Harms | 2012.01.12 at 11:24 AM
Posted by: Elizabeth Harms | 2012.01.12 at 11:25 AM