Thursday, July 18, 2013

How to clone a table row dynamically in HTML

Hi All,

Recently I got into a problem where I had to clone the first row of a table. So I used jquery to get the html code of first row and append it to desired location
Here is code snippt:

$line = $('table tbody tr:first').html();
$(table).find("tbody tr:first").after($line);

While cloning tr tag is not cloned so you need to append it before final appending of code to the desired location. Also you may put these code in some function which needs to be called every time you need to add row.

regards
lalit

No comments:

Post a Comment