Skip to content
Related Articles

Related Articles

jQuery :button Selector

Improve Article
Save Article
  • Last Updated : 14 Nov, 2022
Improve Article
Save Article

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: 

HTML




<!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>

Output: 

 

Example 2: 

HTML




<!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>

Output:

 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!