Reputation: 130
I have this html element
<p>The content</p>
I would like to add a span around the existing text with jquery
<p><span>The content</span></p>
Is there a way to do this ?
Upvotes: 1
Views: 443
Reputation: 67207
You have to use .wrapInner
at this context,
$("p").wrapInner("<span>");
This will wrap the content of paragraph
by a span
element.
Upvotes: 1