Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery if div not id

Tags:

jquery

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; } 
like image 510
tonoslfx Avatar asked Apr 27 '11 12:04

tonoslfx


People also ask

How do I select an element in jQuery without an ID or class?

var noSpace= $('*:not([id])*:not([class])'); // 84 ?

How check ID exists or not in jQuery?

In jQuery, you can use the . length property to check if an element exists. if the element exists, the length property will return the total number of the matched elements. To check if an element which has an id of “div1” exists.

Is not condition in jQuery?

jQuery not() Method: This method returns elements that do not match a defined condition. This method specifies a condition. Elements that do not match the condition are returned, and those that match will be removed. Mostly this method is used to remove one or more than one elements from a group of selected elements.


1 Answers

Use not selector

$("div:not(#sale_wrap)") 
like image 77
z33m Avatar answered Sep 30 '22 06:09

z33m