button selector in jQuery with example



Button selector returns all input elements with type button.



Example :



    <html>
    <head>
    <title>button 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 () {
                $(":button:nth(0)").text("Hello World").css("background-color", "Orange");
            });
        });
    </script>
    </head>
    <body>
    <button type="button" id="submitButton">Button</button>
    <button type="button" id="myButton">Click Me</button>
    </body>
    </html>
    

Demo :





In the above example, we have used button selector. Button selector return all input elements with type button. In the above example the button selector selects the button and applies CSS to it.

0 comments:

Post a Comment