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

js教程评论367 views阅读模式
复制代码 代码如下:

var text = '';

$('div').contents().each(function(){

if(this.nodeType === 3){

text += this.wholeText;

}

});

nodeType

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

企鹅博客
  • 本文由 发表于 2020年9月26日 23:19:49
  • 转载请务必保留本文链接:https://www.qieseo.com/421249.html

发表评论