remove string also removes surrounding tag

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.

  1. 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:
  1. <p>hallo</p>

instead of:
  1. <div><p>hallo</p></div>

It just also deletes the div.