私の要素をクローンすると、私のデモは本当に明確です divを複製して削除しますが、最後の要素(li)は削除してはいけません。 私は行方不明ですか?jquery clone functionネスト削除オプション
この!:
$(document).on("click", 'li.delete',function() {
$(this).closest(".outerDiv").remove();
if ($(this).is(".outerDiv:last")){
return false;
}
DEMOとは何かである:= 0 http://jsfiddle.net/XeELs/86/
jQueryの のvar cloneCount。 。 $( "#アドオンアドレス")をクリックします(関数(){
$("#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;
}
});