Reputation: 321
I am trying to remove few elements from .html() and get a fresh set of elements.I am trying .remove() to delete the elements, but, its not helping me. Can you please help me in this regard ?
Adding the code below with the fiddle link.
https://fiddle.jshell.net/g7kptrac/
Upvotes: 0
Views: 49
Reputation: 2834
$("#wrapper").find(".hide").each(function(){
$(this).remove();
});
Upvotes: 0
Reputation: 10659
this is because $(dom).find(".hide")
doesn't exists anymore as $("#wrapper").html()
return all child element it will return 0
elements. you can try this:-
var dom = $("#wrapper").html();
$("#newList").html(dom);
$("#newList").find(".hide").each(function(){
$(this).remove();
});
or simple:-
$("#newList").find(".hide").remove()
Upvotes: 2