tonoslfx tonoslfx - 5 months ago 6
Javascript Question

jquery if div not id

I want to cut the price off to all input value in all divs, except only one

div sale_wrap
. how do I make an exception with jquery?

<div id="one_wrap">
<input type="checkbox" name="1" value="">
<input type="checkbox" name="1" value="">
</div>
<div id="two_wrap">
<input type="checkbox" name="2" value="">
<input type="checkbox" name="2" value="">
</div>
<div id="sale_wrap">
<input type="checkbox" name="3" value="">
</div>


jquery:

if($("div").attr("id") != "sale_wrap") {
t_balance;
} else {
var sale = t_balance*((100-window.discount_p)/100);
t_balance = sale;
}

Answer

Use not selector

$("div:not(#sale_wrap)")
Comments