The wrapInner method

The wrapInner method wraps the content inside an element in the given tag.

Syntax

The method parameter can be text (possibly with tags), a DOM element, or a jQuery object:

javascript.wrapInner(what to wrap it with);

This is how the selected elements are wrapped with content that will be returned as html text by a custom function. The function is called separately for each of the selected elements:

javascript.wrapInner(function(number in the set));

Example

Let's wrap paragraphs with class www in tag b:

html<p class="www">text</p>
<p class="www">text</p>
<p class="www">text</p>
<p>text</p>
javascript$('.www').wrapInner('<b></b>');

HTML the code will look like this:

html<p class="www"><b>text</b></p>
<p class="www"><b>text</b></p>
<p class="www"><b>text</b></p>
<p>text</p>

See also