如何在现有div中添加HTML元素,但覆盖内容?

Hai*_*ien 1 html jquery

例如我这样的HTML:

<div class='title-post'>The content</div>
Run Code Online (Sandbox Code Playgroud)

现在,我想使用Jquery添加元素以获得如下结果:

<div class='title-post'><span>The content</span></div>
Run Code Online (Sandbox Code Playgroud)

这意味着我添加<span></span>封面内容.

我如何使用Jquery来做到这一点?

谢谢您帮忙.

Tat*_*nit 6

使用JQuery API wrapInner:http://api.jquery.com/wrapInner/

演示 http://jsfiddle.net/rp3bY/

$('.title-post').wrapInner('<span>');
Run Code Online (Sandbox Code Playgroud)