Professional Documents
Culture Documents
Syntax
1. $(":enabled")
1. $("button:enabled")
Example1
In this example, we are styling all enabled form elements using the :enabled selector.
Here, there is a form, including some disabled and enabled elements.
We have to click the given enabled button to see the effect. On clicking the button,
the selector will highlight all enabled elements.
1. <!DOCTYPE html>
2. <html>
3.
4. <head>
5. <title> jQuery :enabled selector </title>
6. <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </
script>
7.
8. <script>
9. $(document).ready(function() {
10. $('button').click(function(){
11. $(":enabled").css({"background-color": "yellow", "border": "2px dashed blue"});
12. });
13. });
14. </script>
15.
16. </head>
17.
18. <body>
19. <form action = "#">
20. <h1> Welcome to the javaTpoint.com </h1>
21. <h2> This is an example of using jQuery :enabled selector </h2>
22.
23. <div>
24. First name: <input type = "text"> <br/> <br/>
25. Middle name: <input type = "text" disabled = "disabled"> <br/> <br/>
26. Last name: <input type = "text"> <br/> <br/>
27. Mobile no.: <input type = "text"> <br/> <br/>
28. Telephone: <input type = "text" disabled = "disabled"> <br/> <br/>
29. <input type = "submit" id = "inp" disabled = "disabled">
30. <button> Click me </button>
31. </div>
32.
33. </form>
34.
35. </body>
36.
37. </html>