Skip to content

Commit 6b08fa5

Browse files
kswedbergeddiemonge
authored andcommitted
Add clarifications to :disabled and :enabled selectors
1 parent 47dd9de commit 6b08fa5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

entries/disabled-selector.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
</signature>
88
<desc>Selects all elements that are disabled.</desc>
99
<longdesc>
10-
<p>As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':disabled')</code> is equivalent to <code>$('*:disabled')</code>, so <code>$('input:disabled')</code> should be used instead. </p>
10+
<p>As with other pseudo-class selectors (those that begin with a ":"), it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':disabled')</code> is equivalent to <code>$('*:disabled')</code>, so <code>$('input:disabled')</code> or similar should be used instead. </p>
11+
12+
<p>Although their resulting selections are usually the same, the <code>:disabled</code> selector is subtly different from the <code>[disabled]</code> attribute selector; <code>:disabled</code> checks the boolean (true/false) value of the element's disabled property while <code>[disabled]</code> checks for the existence of the disabled attribute.</p>
13+
14+
<p>The <code>:disabled</code> selector should only be used for selecting HTML elements that support the <code>disabled</code> attribute (<code>&lt;button&gt;</code>, <code>&lt;input&gt;</code>, <code>&lt;optgroup&gt;</code>, <code>&lt;option&gt;</code>, <code>&lt;select&gt;</code>, and <code>&lt;textarea&gt;</code>).</p>
15+
1116
</longdesc>
1217
<example>
1318
<desc>Finds all input elements that are disabled.</desc>
@@ -20,4 +25,4 @@
2025
</example>
2126
<category slug="selectors/form-selectors"/>
2227
<category slug="version/1.0"/>
23-
</entry>
28+
</entry>

entries/enabled-selector.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
</signature>
88
<desc>Selects all elements that are enabled.</desc>
99
<longdesc>
10-
<p>As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':enabled')</code> is equivalent to <code>$('*:enabled')</code>, so <code>$('input:enabled')</code> should be used instead. </p>
10+
<p>As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':enabled')</code> is equivalent to <code>$('*:enabled')</code>, so <code>$('input:enabled')</code> or similar should be used instead. </p>
11+
12+
<p>Although their resulting selections are usually the same, <code>:enabled</code> selector is subtly different from <code>:not([disabled])</code>; <code>:enabled</code> selects elements that have their boolean disabled property strictly equal to false, while <code>:not([disabled])</code> selects elements that do not have a disabled <em>attribute</em> set (regardless of its value).</p>
13+
14+
<p>The <code>:enabled</code> selector should only be used for selecting HTML elements that support the <code>disabled</code> attribute (<code>&lt;button&gt;</code>, <code>&lt;input&gt;</code>, <code>&lt;optgroup&gt;</code>, <code>&lt;option&gt;</code>, <code>&lt;select&gt;</code>, and <code>&lt;textarea&gt;</code>).</p>
15+
1116
</longdesc>
1217
<example>
13-
<desc>Finds all input elements that are enabled.</desc>
18+
<desc>Find all input elements that are enabled.</desc>
1419
<code><![CDATA[$("input:enabled").val("this is it");]]></code>
1520
<html><![CDATA[<form>
1621
@@ -20,4 +25,4 @@
2025
</example>
2126
<category slug="selectors/form-selectors"/>
2227
<category slug="version/1.0"/>
23-
</entry>
28+
</entry>

0 commit comments

Comments
 (0)