This is just another way to do it, probably the ugliest one so far posted, but I'm just adding to the possibilities. If it were me, I would use the one by Felix Kling.
It basically gets the outerHTML
and innerHTML
substracting one to the other: table.prop('outerHTML').replace(table.prop('innerHTML'), '');
. Here's a demo.
HTML
<table class="some-class" style="border:1px solid #000" id="t">
<tr>
<td>first</td>
</tr>
</table>
JS
$(function () {
$('#t').addClass('another-class');
var table = $('#t')
var html = table.prop('outerHTML').replace(table.prop('innerHTML'), '');
$('body').append($(html).append('<tr><td>second</td></tr>'));
});
CSS
.some-class {
color: #00F
}
.another-class {
color: #00F;
font-size: 18px;
}