$('.element').bind('click', function() { $(this).clone().appendTo('$(.parent)'); });
使用bind绑定, 新生的clone对象不会包含点击事件.
解决方式有二:
1. 使用live() 绑定. live()不仅作用与当前元素,而且也作用于未来的元素. 对应的解绑函数die()
$('.element').live('click', function() {
$(this).clone().appendTo($('.parent'));
});
2. 使用delegate()绑定, 解绑函数undelegate()
$('.parent').delegate('.element', 'click', function() {
$(this).clone().appendTo($('.parent'));
});