I have a table that contains another table which I want to remove with jQuery.
This table is in one of the rows of the original table and I actually want to remove the row.
The original table is a jQuery object with the name table.
<table>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3">
<table>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody></table>
I have tried different ways like the following 4 examples, but without any success:
if ($(table).is('tr')){
if (('tr').(':has(table)') $('tr').remove();
}
if ($(table, 'tr').has('table')) {
$(table).find('table').remove();
};
if ($(table, 'tr').has('table')) {
$('tr').remove();
};
$(table, 'tr').siblings().children('table').remove();
I am not sure whether I am on the right track or barking up the completely wrong tree!!
Any suggestion will be highly appreciated.
This is tested and working fine:
what this is doing :
first get the first tableandthen find and child tablein it and thenremove the closest trwhich has this table.checkout the fiddle.