jQuery :submit Selector


The :submit selector in jQuery is used to select button and input elements with type submit.

Syntax

The syntax is as follows −

$(":submit")

Example

Let us now see an example to implement the jQuery :submit selector −

<!DOCTYPE html>
<html>
<head>
<style>
   .one {
      background-color: green;
      color: white;
      font-size: 18px;
      border: 2px blue dashed;
   }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $(":submit").addClass("one");
   });
</script>
</head>
<body>
<h2>Fill the Form</h2>
<form action="">
Username: <input type="text" name="user"><br>
Set Password: <input type="password" name="password"><br>
Reserved:<input type="radio" name="category" value="r"><br>
Unreserved<input type="radio" name="category" value="u"><br><br>
Products:
<select>
<option>Accessories</option>
<option selected="selected">Clothing</option>
<option>Footwear</option>
<option>Electronics</option>
<option>Books</option>
</select><br><br>
<input type="reset" value="Reset">
<button type="submit">Submit</button>
</form>
</body>
</html>

Output

This will produce the following output −

raja
Published on 05-Nov-2019 12:44:00
Advertisements