Reputation: 9855
I have a web page that has multiple sliders on, all with the class '.viewer'
If I add my jQuery
$('.viewer').carousel('.viewer #simplePrevious', '.viewer #simpleNext');
This doesnt work, Is this because it doesnt know what slider this applies too? Should it not apply to all .viewer elements on the page?
Upvotes: 8
Views: 23864
Reputation: 4947
You should use the jQuery method each()
:
$('.viewer').each(function() {
$(this).carousel('.viewer #simplePrevious', '.viewer #simpleNext');
});
Check the online doc for more information: http://api.jquery.com/each/
Hope this helps mate.
Upvotes: 23