jquery提取元素里的纯文本不包含span等里的内容
(编辑:jimmy 日期: 2025/5/12 浏览:3 次 )
复制代码 代码如下:
var text = '';
$('div').contents().each(function(){
if(this.nodeType === 3){
text += this.wholeText;
}
});
nodeType
元素element 1 属性attr 2 文本text 3 注释comments 8 文档document 9
var text = '';
$('div').contents().each(function(){
if(this.nodeType === 3){
text += this.wholeText;
}
});
nodeType
元素element 1 属性attr 2 文本text 3 注释comments 8 文档document 9
下一篇:jquery得到font-size属性值实现代码