-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathparent-selector.xml
37 lines (37 loc) · 1.74 KB
/
parent-selector.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0"?>
<entry type="selector" name="parent" return="">
<title>:parent Selector</title>
<sample>:parent</sample>
<signature>
<added>1.0</added>
</signature>
<desc>Select all elements that have at least one child node (either an element or text).</desc>
<longdesc>
<p>This is the inverse of <code>:empty</code>. </p>
<p>One important thing to note regarding the use of <code>:parent</code> (and <code>:empty</code>) is that child nodes include text nodes.</p>
<p>The W3C recommends that the <code><p></code> element have at least one child node, even if that child is merely text (see <a href="https://www.w3.org/TR/html401/struct/text.html#edef-P">https://www.w3.org/TR/html401/struct/text.html#edef-P</a>). Some other elements, on the other hand, are empty (i.e. have no children) by definition:<code> <input></code>, <code><img></code>, <code><br></code>, and <code><hr></code>, for example.</p>
<p>To obtain the parents or ancestors of an existing jQuery set, see the <code><a href="/parent/">.parent()</a></code> and <code><a href="/parents/">.parents()</a></code> methods.</p>
</longdesc>
<note id="jquery-selector-extension" type="additional" data-selector=":parent"/>
<example>
<desc>Finds all tds with children, including text.</desc>
<code><![CDATA[
$( "td:parent" ).fadeTo( 1500, 0.3 );
]]></code>
<css><![CDATA[
td {
width: 40px;
background: green;
}
]]></css>
<html><![CDATA[
<table border="1">
<tr><td>Value 1</td><td></td></tr>
<tr><td>Value 2</td><td></td></tr>
</table>
]]></html>
</example>
<category slug="selectors/content-filter-selector"/>
<category slug="selectors/jquery-selector-extensions"/>
<category slug="version/1.0"/>
</entry>