user2048994
user2048994

Reputation: 270

include multiple classes in jquery selector

<ul class="bjqs video">

What is the right way of being able to include and select both classes from the html into the jquery below as at moment it is only including one class:

jQuery(document).ready(function($) {
  $('#banner-video_<?php echo $key; ?>').bjqs({
    animtype:'slide'
  });  
});

Upvotes: 2

Views: 156

Answers (3)

mathtutor
mathtutor

Reputation: 53

Use commas between the selectors as one string if you want to use multiple selectors, and it will work.

Example:

$(".classone , .classtwo").method();

Note that this will match all elements that match either the first selector or the second selector (or both); it doesn't force matched elements to match both. If you want to force matching element having BOTH classes, do this instead:

Example:

$(".classone.classtwo").method();

Upvotes: 2

Ram
Ram

Reputation: 144689

jQuery selectors work like CSS selectors:

$('.bjqs.video') 

http://api.jquery.com/class-selector/

Upvotes: 3

Vish
Vish

Reputation: 383

I would rewrite the it as follows to target the specific ul and the class assigned to it.

$('ul.bjqs.video');

Upvotes: 0

Related Questions