I have a standard table structure like this:
<table id="test">
<th>...</th>
<tr><td>one thing</td></tr>
<tr><td>another</td></tr>
...
...
</table>
I know how to clone the entire table, or the nth row of a table, but what I need is the whole thing, EXCEPT the 2nd, 3rd, 4th etc row of the table, in other words:
<table id="test">
<th>...</th>
<tr><td>one thing</td></tr>
</table>
Ideas please?
"I know how to clone the entire table..."
Then do that, clone the entire table, then remove what you dont need.
A trick to select everything except first child is to use *+*
. +
selector in css mean the matching element on right side next to the element on the left side.
In the end, you can use that :
var $clone = $('#test').clone().find('tr+tr').remove().end();
$clone
will then be your clone table with only the first row.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments