LeB*_*eau 6 javascript jquery text
我有以下内容
<div><span class="myspan">hello</span> this text has no span </div>
Run Code Online (Sandbox Code Playgroud)
在jquery中如何包装div或跨越"this text has span span"文本?
对于您当前的示例,这是我的一行解决方案:
$("div span").detach().prependTo($("div").contents().wrap("<span />").end());
Run Code Online (Sandbox Code Playgroud)
演示: http ://jsfiddle.net/awwTA/