zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jquery提取元素里的纯文本不包含span等里的内容

jQuery 内容 元素 文本 包含 提取 Span
2023-06-13 09:15:06 时间
复制代码代码如下:

vartext="";
$("div").contents().each(function(){
if(this.nodeType===3){
text+=this.wholeText;
}
});

nodeType
元素element 1 属性attr 2 文本text 3 注释comments 8 文档document 9