replacewith - jquery add tag after another tag -



replacewith - jquery add tag after another tag -

i have following:

<h3>my title</h3>

and add together following:

<h3><span>my title</span></h3>

i have tried accomplish following:

$( "<h3>" ).replacewith( "<h3><span>" ); $( "</h3>" ).replacewith( "</span></h3>" );

but above doesn't seem working. approaching in right way?

you can't replace element string.

in case can utilize .wrapinner()

class="snippet-code-js lang-js prettyprint-override">$('button').click(function() { $('h3').wrapinner('<span />'); }) class="snippet-code-css lang-css prettyprint-override">h3 span { color: red; } class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <h3>my title</h3> <button>wrap</button>

jquery replacewith

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -