Jiihad Khattabi
Jiihad Khattabi

Reputation: 55

Using jQuery to add one tag into another tag

got a quandary i was hoping you kind folks could help me out with...

goal:

Using jQuery, I'm trying to add all the occurrences of:

<pre> ... </pre>

with:

<pre><code> ... </code></pre>

Upvotes: 2

Views: 280

Answers (3)

tymeJV
tymeJV

Reputation: 104775

Use the .wrapInner()

$("pre").wrapInner("<code></code>");

Upvotes: 0

j08691
j08691

Reputation: 207901

$('pre').wrapInner('<code>');

Ref: wrapInner

jsFiddle example

Upvotes: 2

Sri Tirupathi Raju
Sri Tirupathi Raju

Reputation: 819

$('pre').html('<code>'+$('pre').html()+'</code>');

Upvotes: 0

Related Questions