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;
});
                To remove elements and content, there are mainly two jQuery methods: remove() - Removes the selected element (and its child elements) empty() - Removes the child elements from the selected element.
length > 0){ var anotherToDo = $("<p>" + newToDo + "</p>"); $("#toDoList"). append(anotherToDo); $("#newToDo"). val(" "); // later when you want to delete it anotherToDo. remove(); } }); });
In jQuery, in order to remove element and content you can use anyone of the following two jQuery methods: Methods: remove() – It is used to remove the selected element (and its child elements). empty() – It is used to removes the child elements from the selected element.
$(".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;
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With