Answers for "How to get the text node of an element?"

1

How to get the text node of an element?

var root = document.querySelector('p'),
    iter = document.createNodeIterator(root, NodeFilter.SHOW_TEXT),
    textnode;

// print all text nodes
while (textnode = iter.nextNode()) {
  console.log(textnode.textContent)
}
Posted by: Guest on December-31-2021
0

what a text node

var div = document.createElement('div');
div.innerHTML = 'Y HALO THAR';
Posted by: Guest on August-27-2020

Code answers related to "How to get the text node of an element?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language