0

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/

3 Answers 3

2

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()

Demo

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your response.. i am looking at updating 'dom' variable with out updating the html DOM.
well you can wrap all html into div like this fiddle.jshell.net/g7kptrac/2 other than you can't do much with that
@freshtoUI glad if that help you happy coding :)
0

Using jquery, you could do this:

$('cssSelector').remove();

Comments

0
    $("#wrapper").find(".hide").each(function(){
    $(this).remove();
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.