jquery removing element
I have to remove certain elements without removing the entire div.For example Here,
<div>
<p>Hello</p>
<h1>Stack Overflow</h1>
<div>This i开发者_开发技巧s 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/
精彩评论