jQuery :enabled Selector


The :enabled selector in jQuery is used to select all enabled input elements.

Syntax

The syntax is as follows −

$(":enabled")

Example

Let us now see an example to implement the :enabled() selector −

<!DOCTYPE html>
<html>
<head>
<style>
   .one {
      background-color: orange;
      font-size: 16px;
      border: 2px blue dashed;
   }
</style>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script>
   $(document).ready(function(){
      $(":enabled").addClass("one");
   });
</script>
</head>
<body>
<h2>Result</h2>
<form>
Username: <input type="text" name="user"><br>
Password: <input type="password" name="passwd" disabled="disabled"><br><br>
<input type="submit" value="Submit"><br>
</form>
</body>
</html>

Output

This will produce the following output −

Updated on: 05-Nov-2019

130 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements