2
<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'
  });  
});
3
  • What is the value of $key? Commented Feb 10, 2013 at 3:06
  • @JonJaques $key is in a for each loop, it is the value for each question number Commented Feb 10, 2013 at 3:28
  • Ahh, wondering if it made a difference in the answer but looks like not. Also, it will work fine regardless - but my ocd says you should make sure the whole document.ready wrapper is outside of the loop. :) Commented Feb 10, 2013 at 3:36

3 Answers 3

3

jQuery selectors work like CSS selectors:

$('.bjqs.video') 

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

Sign up to request clarification or add additional context in comments.

Comments

2

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();

4 Comments

You should note though, 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, which is likely the desired behavior based on that HTML fragment
@nbrooks Oh then in that case just specify both like in css with no comma in between. Question is not very clear IMO
I know, that's why I was just saying you should clarify and make it explicit here. Good answer all the same
@nbrooks thx thats a good idea I added the clarification in my answer.
0

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

$('ul.bjqs.video');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.