Remove all but a specific row from a table
<p>I want to remove all rows apart from the row with id 'row0' from a table:</p>

<pre><code>&lt;table class="mytable"&gt;
    &lt;tr id="row0" class="myrow"&gt;
        &lt;td&gt;aaa&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr class="myrow"&gt;
        &lt;td&gt;bbb&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr class="myrow"&gt;
        &lt;td&gt;ccc&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>But the following JQuery code removes ALL rows:</p>

<pre><code>$('.mytable').children().not('#row0').remove();
</code></pre>

<p>Could someone explain why this happens? I would think that the child with id 'row0' would be excluded, but obviously that's not the case.</p>

<p>I have found another way to do this but still curious why the above method doesn't work:</p>

<pre><code>$('.mytable').find('tr:not(#row0)').remove();
</code></pre>
