嗨,伙计们需要一点帮助..
我知道.live
在 jQuery v1.9 中不再工作是否有任何替代方法可以让我的下面的函数恢复工作我尝试.on()
但.bind()
没有成功。这是小提琴
HTML
<div id="container">
<p>There are 0 boxes</p>
<a href="#" class="more">Add more +</a>
</div>
jQuery
$(".more").click(function() {
$("#container").append("<div class='box'><a href='#'>x</a></div>");
var count = $(".box").length;
$("p").text("There are " + count + " boxes.");
if(count>2){
$(".more").hide();
}
});
$(".box a").live("click", function() {
$(this).parent().remove();
var count = $(".box").length;
$("p").text("There are " + count + " boxes.");
if(count<3)
{$(".more").show();}
});