Reputation: 101
<div>
<p>
<img>
</p>
<p></p>
<p></p>
</div>
How to remove the first <p></p>
but not the childs (img)?
Upvotes: 1
Views: 229
Reputation: 20445
you can use .unwrap()
to unwrap the first p you have to specify the select as first() p also
$("p").first().contents().unwrap()
Working Demo:
$("p").first().contents().unwrap()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div>
<p>
<img>
</p>
<p>aaa
</p>
<p>
</p>
</div>
Upvotes: 5