:enabled
JQ Home <<
Selectors <<
:enabled
UI element states pseudo-class match selector.
Shorthand version $(':enabled')
Description
The :enabled
selector, selects all enabled elements.
- The
:enabled
selector should only be used for selecting HTML elements that support the disabled attribute, these being (<button>, <input>, <optgroup>, <option>, <select>, <textarea>, and <fieldset>). - The
:enabled
selector is subtly different from using the :not() Selector via:not([disabled])
:- The
:enabled
selector matches elements that have their booleandisabled
property strictly set tofalse
. - The :not() Selector using
:not([disabled])
matches elements that do not have adisabled
attribute set (regardless of its value).
- The
- If this selector is not preceded by another selector, the universal selector ("*") is implied and so the whole DOM will be searched. Use another selector as in the examples below to narrow the search and improve performance.
Syntax
Signature | Description |
---|---|
jQuery(':enabled') | UI element states pseudo-class match |
Parameters
None.
Return
N/A.
:enabled
Example
Selectors << Top
Selects all enabled elements.
The following example will check for enabled input elements with an attribute of name (our input fields below) and set a message in them with a yellow background when the button below is clicked.
$(function(){
$('#btn1').on('click', function() {
$("input[name]:enabled").css('backgroundColor', 'yellow')
.val("enter input");
});
});
Please fill in the form:
Related Tutorials
jQuery Basic Tutorials - Lesson 3 - CSS Selectors