Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery :not selector

Tags:

jquery

I am interesting which method is faster: :not selector or not() method. For example in such query:

$(this).find(':input').not(':input[type=button], :input[type=submit], :input[type=reset]').each(function() { ... });

Thank you

like image 579
nKognito Avatar asked Mar 04 '26 06:03

nKognito


2 Answers

See http://jsperf.com/jquery-css3-not-vs-not

:not is on average is about twice as fast.

like image 70
David Lesches Avatar answered Mar 06 '26 18:03

David Lesches


Try this please:

Good read: jQuery selector question (how to select all input fields on a form EXCEPT buttons and checkbox)

http://api.jquery.com/not-selector/

This should help your cause :)

Code

$(this).find(':input:not(:button):not(:submit):not(:reset)').each(function() { ... });
like image 21
Tats_innit Avatar answered Mar 06 '26 20:03

Tats_innit