remove string also removes surrounding tag
Hi
I am struggling to remove a specific tag from a string. But it is also deleting the outer tag. Why is that? Hope someone can give me a hint. Thanks in advance.
- var data = '<div><h1>heading</h1><p>hallo</p></div>';
var new_data = $(data).find('h1').remove().end();
alert(new_data.html());
The alert is:
- <p>hallo</p>
instead of:
- <div><p>hallo</p></div>
It just also deletes the div.