0
我的演示,真的很清楚,当我克隆我的元素 克隆和删除div但是,最后一个元素(李)不应该被删除。 我错过了什么?jQuery的克隆功能嵌套删除选项
要做些什么与此!:
$(document).on("click", 'li.delete',function() {
$(this).closest(".outerDiv").remove();
if ($(this).is(".outerDiv:last")){
return false;
}
DEMO: http://jsfiddle.net/XeELs/86/
JQUERY VAR cloneCount = 0; 。 $( “#附加地址”)点击(函数(){
$("#to-add-address").clone()
.attr("id", "to-add-address_Clone" + cloneCount)
.insertAfter("#to-add-address");
$("#clone", "#to-add-address_Clone" + cloneCount)
.attr("id", "clone_Clone" + cloneCount);
cloneCount++;
});
$(document).on("click", '.options li a',function() {
$(this).closest(".options").find('li a').removeClass('selected');
$(this).addClass('selected');
});
$(document).on("click", 'li.delete',function() {
$(this).closest(".outerDiv").remove();
if ($(this).is(".outerDiv:last")){
return false;
}
});