开发者

jquery - remove specific element from cloned node

开发者 https://www.devze.com 2022-12-31 19:34 出处:网络
Im trying to clone tree, remove one element from it and then append result to new place. But the problem is that element is not deleted, it always append original tree.

Im trying to clone tree, remove one element from it and then append result to new place. But the problem is that element is not deleted, it always append original tree.

$(".js-parent-trigger").click(function() {        
    var commentForm = $("#js-add-comment-wrapper").clone(true)开发者_如何学Python.css("margin", "10px").remove(".js-add-comment-title");
    $(this).parents(".js-comment-wrapper").append(commentForm);
    return false;
});


$(".js-parent-trigger").click(function() {        
    var commentForm = $("#js-add-comment-wrapper").clone(true).css("margin", "10px");
    commentForm.find(".js-add-comment-title").remove();
    $(this).parents(".js-comment-wrapper").append(commentForm);
    return false;
});


Couldn't help making it one big statement:

$(".js-parent-trigger").click(function() {        
   $("#js-add-comment-wrapper").clone(true).css("margin", "10px")
         .find(".js-add-comment-title").remove()
         .end().appendTo('.js-commet-wrapper');
    return false;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消