tags:

views:

28

answers:

2

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).css("margin", "10px").remove(".js-add-comment-title");
    $(this).parents(".js-comment-wrapper").append(commentForm);
    return false;
});
+2  A: 
$(".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;
});
patrick dw
+1  A: 

Couldn't help making it one big statement, lol

$(".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;
});

(this was for fun, vote up patrick's answer ya?)

Dan Heberden
+1 For the sheer beauty of it! :)
patrick dw