jQuery :enabled Selector

jQueryWeb DevelopmentFront End Technology

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 −

raja
Published on 05-Nov-2019 11:45:04
Advertisements