Jquery 移除不带';不能在克隆对象中工作

Jquery 移除不带';不能在克隆对象中工作,jquery,clone,Jquery,Clone,此代码中的删除对象在jquery 1.5中工作正常,但在jquery 1.6中不起作用: <!DOCTYPE html> <html> <head> <style>.content {border: 1px solid #333;} .delete {color: red;}</style> <script src="http://code.jquery.com/jquery-1.5.js"></script>

此代码中的删除对象在jquery 1.5中工作正常,但在jquery 1.6中不起作用:

<!DOCTYPE html>
<html>
<head>
<style>.content {border: 1px solid #333;} .delete {color: red;}</style>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<div id="master">
<div class="content">Some content <span class="delete">Delete</span></div>
</div>
<div class="clone">Clone</div>
<script>
    $(".clone").click(function () {
        $("#master").find(".content").last().clone().appendTo("#master");
    });

    $(".delete").click(function () {
        $(this).parents(".content").remove();
    });
</script>
</body>
</html>

.content{边框:1px实心#333;}。删除{颜色:红色;}
删除一些内容
克隆
$(“.clone”)。单击(函数(){
$(“#master”).find(“.content”).last().clone().appendTo(“#master”);
});
$(“.delete”)。单击(函数(){
$(this.parents(“.content”).remove();
});

使用jQuery1.6+我可以只删除第一个元素。为什么不起作用?

中的
clone()
关于可选的
withDataAndEvents
参数似乎存在问题

从文件中:

在jQuery 1.5.0中,默认值不正确;在1.5.1及更高版本中,它被改回false

因此,您的代码应该是:

$(".clone").click(function () {
    $("#master").find(".content").last().clone(true).appendTo("#master");
});

$(".delete").click(function () {
    $(this).parents(".content").remove();
});