The platform I’m building a website on adds p tags around image links in wysiwyg mode and this messes up the layout. Is there anyway I can use jQuery to strip the p tags if it’s surrounding an image?
<div class="post">
<p><a href="link"><img src="image"></a></p>
<p><a href="link"><img src="image"></a></p>
</div>
Example: http://jsfiddle.net/6z4Sv/
If there’s some variation to the hierarchy inside the
pelements, you can do this:Example: http://jsfiddle.net/6z4Sv/1/
And you can use
div.postat the beginning of the selector if you only want to affectpelements that descend from that class.You can make the selector more or less specific as need be.