8

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?

Liam
  • 9,725
  • 39
  • 111
  • 209

1 Answers1

23

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.

Chase Sandmann
  • 4,795
  • 3
  • 30
  • 42
Littm
  • 4,923
  • 4
  • 30
  • 38