Skip to content

Commit d07a2f4

Browse files
committed
Entries: Document $.fn.labels
Fixes #270
1 parent 95ac547 commit d07a2f4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

entries/labels.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<entry name="labels" type="method" return="jQuery">
3+
<title>.labels()</title>
4+
<desc>Finds all label elements associated with the first selected element.</desc>
5+
<longdesc>
6+
<p>This can be used to find all the <code>&lt;label&gt;</code> elements associated with an <code>&lt;input&gt;</code> element. The association can be through nesting, where the label is an ancestor of the input, or through the <code>for</code> attribute on the label, pointing at the <code>id</code> attribute of the input. If no labels are associated with the given element, an empty jQuery object is returned.</p>
7+
<p>This methods mimics the native <code>labels</code> property, which isn't supported in all browsers. In addition, this method also works for document fragments.</p>
8+
</longdesc>
9+
<signature>
10+
<added>1.12</added>
11+
</signature>
12+
<example>
13+
<height>100</height>
14+
<desc>Highlight all labels of the input element</desc>
15+
<code><![CDATA[
16+
$( "input" ).labels().addClass( "ui-state-highlight" )
17+
]]></code>
18+
<html><![CDATA[
19+
<label>
20+
Firstname
21+
<input id="name">
22+
</label>
23+
<label for="name">Please enter your name</label>
24+
]]></html>
25+
</example>
26+
<category slug="methods"/>
27+
<category slug="overrides"/>
28+
<category slug="utilities"/>
29+
</entry>

0 commit comments

Comments
 (0)