I have to remove certain elements without removing the entire div.For example Here,
<div>
<p>Hello</p>
<h1>Stack Overflow</h1>
<div>This is a wonderful site</div>
</div>
I have to remove <p> and <div> tags without emptying whole div.Is there any usage of child selectors for removing like this in jquery.
try this $("div").children("p,div").remove();
Using children() you can select the element you wish to remove.
Demo: http://jsfiddle.net/tT97f/
Another method is using child selector > for example $("div > p, div > div").remove();
Demo: http://jsfiddle.net/tT97f/1/
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