jQuery :input Selector

The jQuery :input selector selects all the input type elements in a form. It selects every input elements including textarea, select box, and button. This can be useful when you want to select the input form elements.

jQuery :input Selector

Syntax of the Selector

The syntax of jQuery :input selector is given below.

Syntax
$(“:input”)

The above syntax requires no arguments to pass to the selector. However, if you want to select only the specific input element. You have to use the tag name. Suppose, if you want to select only the select box. You have to specify the tag name select before the selector. You have to use the selector as $("select:input").

jQuery :input Selector Select All Types of Input Elements

When you want to select the form elements which are using for user inputs. You have to use this selector. It selects every element in a form including the button element. See the example below the selector selects each and every form elements.

Example

Test it Live

Output





The above example showing all the selected form elements with the button element. The selector selects the input, select box, and button elements to apply the background color. It adds a ‘yellow’ color to each and every form elements to highlight them

If you have any queries regarding this tutorial post, please comment below.

Also tell me, what other methods you are using with the selector by commenting below.

References