jQuery plugin: wrapInner

Wrap my element on the inside, please!

Syntax

$(element).wrapInner(Html)

Parameters

Html	Required. String that specifies the html code that will be warped inside the elment. 

Return Value

none

Remarks

Tested successfully on:
– Firefox > 1.x 
– Opera 8.54, Opera 9.0 Beta 2 
– IE 5.5, IE 6.x, IE 7 Beta 2
– Safari 2.03

Download

Download jquery-plugin-wrapinner.js (1kb uncompressed)

Example

<p>Hello world!</p>
<script>
$('p').wrapInner('<a href="/"><\/a>');
</script>

Returns:
<p><a href="/">Hello world!</a></p>

Hello World!