JS shorthand for multiple functions

Hi,

I’m currently doing this

$(document).ready(function(){
  $('.slider1').bxSlider({
    slideWidth: 300,
    minSlides: 2,
    maxSlides: 3,
    slideMargin: 10
  });
});
</script>
<script>
$(document).ready(function(){
  $('.slider2').bxSlider({
    slideWidth: 300,
    minSlides: 2,
    maxSlides: 3,
    slideMargin: 10
  });
});

Surely I can shorten it like;

$(document).ready(function(){
  $('.slider1','.slider2').bxSlider({
    slideWidth: 300,
    minSlides: 2,
    maxSlides: 3,
    slideMargin: 10
  });
});
</script>

Indeed you can, although this:

$('.slider1','.slider2').bxSlider({

should be:

$('.slider1, .slider2').bxSlider({

See: http://api.jquery.com/multiple-selector/

You were very close, instead of comma separating the strings themselves you simply add a comma inside the first string itself hence the following:

'.slider1[B][COLOR=#FF0000]','[/COLOR][/B].slider2'

will become.

'.slider1[B][COLOR=#FF0000], [/COLOR][/B].slider2'

Many thanks both - Pullo thanks for the link apologies for being lazy I should have looked at this beforehand.

Chris.upjohn - my best mate is called Chris John, what’s the chances?