Answers for "js find all text elements"

0

js find all text elements

function textNodesUnder(node){
  var all = [];
  for (node=node.firstChild;node;node=node.nextSibling){
    if (node.nodeType==3) all.push(node);
    else all = all.concat(textNodesUnder(node));
  }
  return all;
}
Posted by: Guest on June-11-2021
0

js find all text elements

function textNodesUnder(el){
  var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false);
  while(n=walk.nextNode()) a.push(n);
  return a;
}
Posted by: Guest on June-11-2021

Code answers related to "js find all text elements"

Code answers related to "Javascript"

Browse Popular Code Answers by Language