Skip to content
Related Articles
Open in App
Not now

Related Articles

jQuery | :input Selector

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 22 Feb, 2019
Improve Article
Save Article

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



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.

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


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!