Using jQuery to gather all text nodes from a wrapped set, separated by spaces

后端 未结 3 2072
盖世英雄少女心
盖世英雄少女心 2020-12-15 11:37

I\'m looking for a way to gather all of the text in a jQuery wrapped set, but I need to create spaces between sibling nodes that have no text nodes between them.

For

3条回答
  •  攒了一身酷
    2020-12-15 11:58

    This is the simplest solution I could think of:

    $("body").find("*").contents().filter(function(){return this.nodeType!==1;});
    

提交回复
热议问题