Skip to content
Related Articles

Related Articles

jQuery | :button Selector
  • Last Updated : 26 Feb, 2019

The jQuery :button selector selects button elements and input elements with type=”button”. The button element is not selected if we use input=” button” as a selector.

Syntax:

$(":button")

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <script src=
  </script>
   
  <script>
        $(document).ready(function() {
            $(":button").css(
              "background-color", "lightgreen");
        });
    </script>
</head>
  
<body>
  
    <center>
        <form action="">
            Name:
            <input type="text" 
                   name="user">
            <br> Password:
            <input type="password" 
                   name="password">
            <br>
            <button type="button">
              Button
          </button>
            <br>
            <input type="reset" 
                   value="Reset">
            <input type="submit"
                   value="Submit">
            <br>
        </form>
    </center>
  
</body>
  
</html>

chevron_right


Output:

Example-2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <script src=
  </script>
  
</head>
  
<body>
    <input type="button" 
           value="Test" />
    <br>
    <input id="txtName" 
           type="text" />
    <input type="submit" 
           value="Test" />
    <br>
  
    <button id="button1">
      This is a button
  </button>
    <br>
  
    <script>
        $(function() {
            $(":button").css(
            "border", "10px dashed green");
        });
    </script>
</body>
  
</html>

chevron_right


Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :