jQuery | :input Selector

The :input selector in jQuery is used to select input elements. This selector also used with button element.

Syntax:

$(":input")

Note: jQuery :input selector not only selects input elements but also Buttons, Dropdowns and Textarea elements.



Example: This example use :input selector to count all input elements.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head
    <title>
        jQuery :input Selector
    </title>
      
    <style
        body { 
            width: 35%; 
            height: 150px; 
            border: 2px solid green; 
            padding: 35px; 
            margin: 10px; 
        }
    </style>
      
    <script src=
    </script
</head
  
<body
  
    <input type="text" value="GeeksforGeeks">
      
    <button type="button">
        Simple Button
    </button><br>
      
    <select>
        <option>Option</option>
    </select>
      
    <textarea></textarea>
      
    <h4 id="GFG"></h4>
      
    <!-- jQuery code to count all elements 
        selected by :input selector -->
    <script
        $(document).ready(function() {
            var allInputs = $(":input");
            $("#GFG").text("Found " + allInputs.length 
                    + " elements selected."); 
        });
    </script
</body
  
</html>                        

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.