Mar*_*ger 14
要包装除包含空格之外的所有文本节点:
$('body *').contents().filter(function() {
return (this.nodeType == 3) && this.nodeValue.match(/\S/);
}).wrap("<span />")
Run Code Online (Sandbox Code Playgroud)
要包装所有文本节点,包括仅包含空格的节点:
$('body *').contents().filter(function() {
return (this.nodeType == 3) && this.nodeValue.length > 0;
}).wrap("<span />")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8571 次 |
| 最近记录: |