title: jQuery check if any div on page has specific class in an if statement
body: <p>I'm using Bootstrap switch <a href="https://github.com/nostalgiaz/bootstrap-switch" rel="nofollow">https://github.com/nostalgiaz/bootstrap-switch</a> and have a few switches in a table.</p>
  
  <p>When a switch is toggled I check the state of the switch and have a basic if condition. When the data.value is false the switch has been turned off. I tried to run another conditional to check if any of the switches in the table, had the <code>switch-on</code> class, and if so hide a series in high charts. This isn't working as expected. I'm pretty sure my selector is ok <code>div.make-switch &gt; div</code> is selecting the first nested div, which has the class <code>switch-on</code> or <code>switch-off</code></p>
  
  <p>Whats wrong with the code? Shouldn't my second if condition fire every time the switches are turned off and check if any of the switches are on?</p>
  
  <p>Thanks</p>
  
  <p>The HTML rendered by the on and off states is below, </p>
  
  <pre><code>if(data.value == true){
  // Switch is on
  }
  else if (data.value == false){
  // Switch is off
  
      if ($('div.make-switch &gt; div').hasClass('switch-on')){
  
          series.hide();
      }
  }
  </code></pre>
  
  <p>Off state has class <code>.switch-off</code> in nested div</p>
  
  <pre><code>&lt;div class="make-switch switch-mini has-switch"&gt;&lt;div class="switch-off switch-animate"&gt;&lt;input name="" id="create-switch" type="checkbox"&gt;&lt;span class="switch-left switch-mini"&gt;ON&lt;/span&gt;&lt;label class="switch-mini" for="create-switch"&gt;&amp;nbsp;&lt;/label&gt;&lt;span class="switch-right switch-mini"&gt;OFF&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>On state has class <code>.switch-on</code> in nested div</p>
  
  <pre><code>&lt;div class="make-switch switch-mini has-switch"&gt;&lt;div class="switch-on switch-animate"&gt;&lt;input name="" id="create-switch" type="checkbox"&gt;&lt;span class="switch-left switch-mini"&gt;ON&lt;/span&gt;&lt;label class="switch-mini" for="create-switch"&gt;&amp;nbsp;&lt;/label&gt;&lt;span class="switch-right switch-mini"&gt;OFF&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>