开发者

How to copy html with events jQuery

Could you please tell me how to copy events, if I copy some html? I have a function to copy:

function add_to_order( row, row_input_value ) {



  $('#buffer').html( row ).find('td:first').remove(); // add row to buffer and remove the first td element

   $('#buffer').append('<td class="delete"><span class="remove-from-order button minus" ></s开发者_运维百科pan></td>').html(); // append minus

   var row_clear = $('#buffer').html();

   $.post('core/ajax.linker.php',
  {action: 'add_to_sess', data: row_clear}
   );

   $('.items').append('<tr class="fresh">'+row_clear+'</tr>').find('input.add-amt:last').val(row_input_value); // highlight new

   $('.fresh > td > .add-key').attr("class", '');
   $('.fresh > td > .add-value').attr("class", '');
   count_sum();
    }

And a function, that should work after the previous copied html:

    $('input.add-amt').keyup( function () {
       var amt = $(this).val();
       count_sum();
    });

In fact, the first one copies the textfield, and the second have to get the value of that field, but it doesn't.

Any help will be appreciated


You should take a look at jQuery's clone-function. It duplicates all selected nodes instead of their string representation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜