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">
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">
then the selector looks the same, but without a space between the classes
This won't work if one of the classes is represented by a variable. In that case, do this:


Add new comment


  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Missing filter. All text is removed