input selector in jQuery with example



Input selector returns all input elements.


Example :



    <html>
    <head>
    <title>input Selector</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
    <script type="text/javascript">
    $(document).ready(function()
    {
    $("#myButton").click(function()
    {
    $(":input").text("Hello World");
    });
    });
    </script>
    </head>
    <body>
    <button id="myButton">Click Me</button>
    <button onclick="location.reload()">Reset</button>
    </body>
    </html>
    

Demo :






In the above example, we have used input selector. Input selector return all input elements. In the above example the input selector selects the button element and changes text of the button.

0 comments:

Post a Comment