JQuery cloning. click event not firing newly created cloned rows

This code works fine, almost let's say I have 10 rows on the table, I click on the top row, it gets CLONED and then ADDED at the bottom of the table, and the original is REMOVED, repeat these steps 5 times. Now I end up with five lines that have been cloned at the bottom.

Now if I click on the first cloned row, it should be cloned and added from the bottom, but the click event is not fired.

$('.tog').live('click', function() {
   var $btn = $('#'+dataId);
   var $clonedRow = $btn.closest('tr').clone();

   $clonedRow.find('*').andSelf().filter('[id]').each( function(){
      this.id += '_clone';

   $btn.closest('tbody').append( $clonedRow );




source to share

2 answers

Try to do:

var $clonedRow = $btn.closest('tr').clone(true);




Check out this demo: http://jsfiddle.net/6Km2W/1/



All Articles