Help me reduce code repetition in a simple jQuery function
- by user339876
I have built a carousel using the jQuery cycle plugin. I have 4 links that jump to relevent slides. Right now I have a chunk of code for each link. I am trying to create a single multi-purpose function.
$('#features-slide0').click(function() {
$('#features-slides').cycle(0);
return false;
});
$('#features-slide1').click(function() {
$('#features-slides').cycle(1);
return false;
});
$('#features-slide2').click(function() {
$('#features-slides').cycle(2);
return false;
});
$('#features-slide3').click(function() {
$('#features-slides').cycle(3);
return false;
});
I have a rel value on each link that carries the number of the slide. How can I use that to create a single block of code that takes care of the link jump?