How to change:
<p class="myClass">Lorem Ipsum (and maybe other nested tags)</p>
into:
<code class="myClass">Lorem Ipsum (and maybe other nested tags)</code>
?
This is an offline job. It’s just an update but there are thousands of ps that I need to change into codes.
You can use contents() to obtain the element’s children (including text nodes), then combine unwrap() and wrapAll():
Update: If you have more than one
<p>element, you have to iterate over them with each() to avoid reparenting all of them inside a single<code>element: