I would like to get all form elements that don't have a specific CSS class. Example:
<form>
<div>
<input type="text" class="good"/>
<input type="text" class="good"/>
<input type="text" class="bad"/>
</div>
</form>
What selector should I use to select all elements that don't have 'bad' css class?
Thank you.
您可以使用not()过滤器:
$("input").not(".bad")
You can also use the not selector :
$('input:not(".bad")').hide();
Note the quotes are not needed:
$('input:not(.bad)').hide();
See:
$("input:not(.bad)")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.