Skip to content Skip to sidebar Skip to footer

Clone And Delete Selected Row To Another Table

I am tring to clone selected object from one table to another . Till now i am getting the id of selected td to be cloned . Following is the code i am trying. ).html(); $('#otherTable tbody').append('<tr>'+row+'</tr>');

Solution 2:

prepend() and append() functions should do the trick. Another thing I had tried way back in js with a similar scenario was using document.getElementById(tableIDA) to first get the concerned table and then using tableA.insertRow(rowCountA) [where rowCountA is the row count of Table A], followed by tableA.insertCell() function and lastly, cell.appendChild(). It seems long but its actually very easy and procedural to use. May be this will help your purpose.

Solution 3:

No need to explicitly .clone(), in case that ever came across your mind.

You can avoid rebuilding elements from HTML (as you might lose any event handlers if you are not using event delegation) by directly using .append(), .appendTo(), prepend() or prependTo()

Psuedo-codes:

$A.appendTo($B);
//or
$B.append($A);

Example:

$('tr.highlighted').appendTo( $('#otherTable tbody') );

The reverse also works:

$('#otherTable tbody').append($('tr.highlighted'));

Post a Comment for "Clone And Delete Selected Row To Another Table"