javascript replace div tags for p tags where it has no class
- by Tom
I would like to replace div tags for p tags but only when the div tag does not have a class.
So this:
<div class="myDiv">
<div>sdfglkhj sdfgkhl sdfkhgl sdf</div>
<div>dsf osdfghjksdfg hsdfg</div>
</div>
Would become:
<div class="myDiv">
<p>sdfglkhj sdfgkhl sdfkhgl sdf</p>
<p>dsf osdfghjksdfg hsdfg</p>
</div>
I've tried .replace("<div>", "<p>").replace("</div>","</p>") but this replaces the closing tag of the one with a class.