Hey guys just a quick question, I tried to replicate this: Clone a div and change the ID's of it and all it's children to be unique
Its exactly what I want and need but I can't seem to make it work.
This is what I got:
<div id="current_users">
<table id="user_list">
<tr id="user-0">
<td id="first_name-0">Jane</td>
<td id="last_name-0">Doe</td>
</tr>
<tr id="user-1">
<td id="first_name-1">John</td>
<td id="last_name-1">Doe</td>
</tr>
</table>
</div>
<button id="button" onclick="duplicate()">Click me</button>
<script>
function duplicate() {
$("#current_users").clone(false).find("*[id]").andSelf().each(function () { $(this).attr("id", $(this).attr("id") + "_cloned"); });
}
</script>
There are no errors showing up in my console, I tried looking for other solutions but this is the best I found. Thanks for those who can help