I have 8 divs. Each div has the class ‘pre-loader’. In addition to thas class, six have the class ‘loader’. Below those divs I have a button. When clicked I have an alert that is displaying the number of divs that have the class pre-loader and the class loader (6). What I would like, is that the alert displays the number of div that have the class ‘pre-loader’ but not the class ‘loader’ (2). Hope someone can help. Thank you in advance for your replies. Cheers. Marc
my html:
<div class="pre-loader loader">text</div></br>
<div class="pre-loader loader">text</div></br>
<div class="pre-loader loader">text</div></br>
<div class="pre-loader loader">text</div></br>
<div class="pre-loader loader">text</div></br>
<div class="pre-loader loader">text</div></br>
<div class="pre-loader">text</div></br>
<div class="pre-loader">text</div></br>
<input id="btn" type="submit" value="click">
my js:
$(document).on({
click: function() {
alert($('.pre-loader.loader').length);
}
}, "#btn");
You want to use the :not selector
Hope this helps
http://api.jquery.com/not-selector/