What a difference a space makes

Sometimes you need your selector to look for two classes...but what do you do when both classes are for the same element?
In normal circumstances, you might be looking to select class=red and class=blue
<div class="red">
  <div class="blue">
  </div>
</div>
and would use the selector
$('.red .blue')
However, if you need to select the element that has both red and blue as its classes
<div class="red blue">
</div>
then the selector looks the same, but without a space between the classes
$('.red.blue')
This won't work if one of the classes is represented by a variable. In that case, do this:
$('.red.'+var)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Of course, the Drupal Community isn't the only place to give back. It's a complex world, and there are as many worthy causes as their are melodies, with most being served by multiple charitable organizations. Here are a few of those that strike a 7th chord with me.