button selector in jQuery with example

Button selector returns all input elements with type button.

Example :

    <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");
    <button type="button" id="submitButton">Button</button>
    <button type="button" id="myButton">Click Me</button>

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.


Post a Comment