jQuery :input Selector Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The jQuery :input selector in jQuery is used to select input elements. This selector is also used with button element. Syntax: $(":input")Note: jQuery :input selector not only selects input elements but also Buttons, Dropdowns, and Textarea elements. Example 1: This example use :input selector to count all input elements. HTML <!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= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </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> Output: Example 2: This example use :input selector to change the color of all buttons. HTML <!DOCTYPE html> <html> <head> <title> jQuery :input Selector </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> </head> <body> <input type="text" value="GeeksforGeeks"><br> <button type="button"> Simple Button </button> <br> <select> <option>Option</option> </select> <br> <textarea></textarea> <h4 id="GFG"></h4> <button>Change color</button> <!-- jQuery code to count all elements selected by :input selector --> <script> $(document).ready(function () { $("button").click(function () { $("button").css("background-color","green"); }); }); </script> </body> </html> Output: Comment P parammittal162 Follow Improve P parammittal162 Follow Improve Article Tags : JQuery Explore jQuery Tutorial 8 min read Getting Started with jQuery 4 min read jQuery Introduction 7 min read jQuery Syntax 2 min read jQuery CDN 4 min read jQuery SelectorsJQuery Selectors 5 min read jQuery * Selector 1 min read jQuery #id Selector 1 min read jQuery .class Selector 1 min read jQuery EventsjQuery Events 4 min read jQuery bind() Method 2 min read jQuery blur() Method 1 min read jQuery change() Method 2 min read jQuery EffectsjQuery animate() Method 2 min read jQuery clearQueue() Method 2 min read jQuery delay() Method 2 min read jQuery HTML/CSSjQuery addClass() Method 2 min read jQuery after() Method 1 min read jQuery append() Method 2 min read jQuery TraversingjQuery | Traversing 4 min read jQuery add() method 1 min read jQuery addBack() Method 2 min read Like