有没有办法使用 jQuery 删除未包含在任何标签中的文本
<p>This is some text</p>
This is "unwrapped" text //to be removed
<span>some more text</span>
感谢您的帮助
使用来自的答案这个问题:
$(elem)
.contents()
.filter(function() {
return this.nodeType == 3; //Node.TEXT_NODE
}).remove();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)