:input
is a jQuery extension while input
is a CSS selector.
textarea
、button
和select
元素将由前者匹配,但后者不匹配.
The latter is faster, so use it for your specific radio
example. Use :input
when you want "all form elements" even if they aren't strictly <input>
tags. Even in that case, the recommendation is to use a standard CSS selector first, then use .filter(':input')
on that set.
Because :input is a jQuery extension and not part of the CSS
specification, queries using :input cannot take advantage of the
performance boost provided by the native DOM querySelectorAll()
method. To achieve the best performance when using :input to select
elements, first select the elements using a pure CSS selector, then
use .filter(":input").
In the 1.7.2 source, the :input filter tests a regular expression against the nodeName:
input: function( elem ) {
return (/input|select|textarea|button/i).test( elem.nodeName );
},