最近在写一个项目,出现了瓶颈。js没学好。分离出一个demo测试了一下。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MyCalendar</title>
<script type="text/javascript" src="jquery-1.6.min.js"></script>
<script type="text/javascript">
$(function() {
$("#btn").click(function() {
$("#hide_child .child").clone().show().appendTo("#parent");
});
$(".delete").click(function() {
alert("delete");
});
});
</script>
</head>
<body>
<input type="button" id="btn" value="增加"></input>
<div id="parent">
<div class="child">
<input type="button" value="删除" class="delete">
</div>
<div id="hide_child">
<div class="child" style="display: none">
<input type="button" value="删除" class="delete">
</div>
</div>
</div>
</body>
</html>
可能clone没有把事件监听也clone进去吧。 除了第一个删除有反应,其他的全没有反应啊。why