Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (29 sloc) 1.575 kb
<?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 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>&lt;p&gt;</code> element have at least one child node, even if that child is merely text (see <a href="http://www.w3.org/TR/html401/struct/text.html#edef-P">http://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> &lt;input&gt;</code>, <code>&lt;img&gt;</code>, <code>&lt;br&gt;</code>, and <code>&lt;hr&gt;</code>, for example.</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>
Jump to Line
Something went wrong with that request. Please try again.