I have a table and a link below it. I need to be able to click that link, copy the table above, with all its contents and paste it below that original table.
<table>
...
</table>
<br>
<a href="#" id="copyTbl">copy</a>
I tried something like this, but failed:
$("#copyTbl").click(function() {
$(this).closest("table").html().clone().appendTo("br");
});
Am I stringing it improperly?
Try something like this, short and simple:
http://jsfiddle.net/wfqa7/6/
edit: be careful when cloning elements with IDs 😛
edit: handle IDs when cloning http://jsfiddle.net/wfqa7/8/