javascript - jQuery 环绕文本

标签 javascript jquery text

我有以下内容

<div><span class="myspan">hello</span> this text has no span </div>

在 jQuery 中,我如何包装一个 div 或围绕“此文本没有跨度”文本进行跨度?

最佳答案

对于您当前的示例,这是我的单行解决方案:

$("div span").detach().prependTo($("div").contents().wrap("<span />").end());

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

关于javascript - jQuery 环绕文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13527778/

相关文章:

javascript - 事件循环、libuv和v8引擎的关系

matplotlib -\frac{}{} 在 plt.text 中不起作用?

javascript - 由于标题固定,jQuery 滚动偏移

javascript - react native Android : Contain text to inside parent view on a single line

python - 从文件中删除行

javascript - REACT 中的 UnCaughtType 错误, Hook 事件处理程序时的 js

javascript - 从 items[] 数组中选择九个已打乱顺序且不重复的项目

javascript - jQuery UI 对话框没有打开第二次

javascript - jQuery 数据表不刷新

jquery - clearInterval 在一种情况下会失败,但在另一种情况下不会失败