我有以下内容
<div><span class="myspan">hello</span> this text has no span </div>
在 jQuery 中,我如何包装一个 div
或围绕“此文本没有跨度”文本进行跨度?
最佳答案
对于您当前的示例,这是我的单行解决方案:
$("div span").detach().prependTo($("div").contents().wrap("<span />").end());
关于javascript - jQuery 环绕文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13527778/