Skip to content

Commit febcc19

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

entries/labels.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
<added>1.12</added>
10+
<example>
11+
<height>100</height>
12+
<desc>Highlight all labels of the input element</desc>
13+
<code><![CDATA[
14+
$( "input" ).labels().addClass( "ui-state-highlight" )
15+
]]></code>
16+
<html><![CDATA[
17+
<label>
18+
Firstname
19+
<input id="name">
20+
</label>
21+
<label for="name">Please enter your name</label>
22+
]]></html>
23+
</example>
24+
<category slug="methods"/>
25+
<category slug="overrides"/>
26+
<category slug="utilities"/>
27+
</entry>

0 commit comments

Comments
 (0)