Clone closest row from a href
I have a code that is supposed to duplicate the row that I specify. My
table is made dynamically so I am not able to define an id. I want to be
able to click a button on the specified row and find the closest tr to
duplicate.
The code that is supposed to duplicate is:
function cloneRow()
{
var row = $(this).closest('tr'); // find row to copy
var table = document.getElementById("ScannedItems");
var clone = row.cloneNode(true); // copy children too
clone.id = "newID";
table.appendChild(clone);
}
I am needing to change var row = $(this).closest('tr'); to something else
but I don't know what to change it to so I can get the closest tr from the
a href that is clicked.
Or just duplicate the same row that the a is clicked on.
The a href looks like this
<a onclick='cloneRow();'><span class='glyphicon glyphicon-plus'
style='padding-right:15px;'>
No comments:
Post a Comment