jquery - remove specific element from cloned node
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;
});
精彩评论