Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (28 sloc) 1.32 KB
<?xml version="1.0"?>
<entry type="selector" name="empty" return="">
<title>:empty Selector</title>
<desc>Select all elements that have no children (including text nodes).</desc>
<p>This is the inverse of <code>:parent</code>. </p>
<p>One important thing to note with :empty (and :parent) is that child elements 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 Some other elements, on the other hand, are empty (i.e. have no children) by definition: &lt;input&gt;, &lt;img&gt;, &lt;br&gt;, and &lt;hr&gt;, for example.</p>
<desc>Finds all elements that are empty - they don't have child elements or text.</desc>
<code><![CDATA[$("td:empty").text("Was empty!").css('background', 'rgb(255,220,200)');]]></code>
td { text-align:center; }
<html><![CDATA[<table border="1">
<tr><td>TD #0</td><td></td></tr>
<tr><td>TD #2</td><td></td></tr>
<category slug="selectors/content-filter-selector"/>
<category slug="version/1.0"/>
Something went wrong with that request. Please try again.