element.
childNodes
returns an array of an element's child nodes. JS
function setText() {
    let a = document.getElementById("demo");
     let arr = a.childNodes;
     for(let x=0;x<arr.length;x++) {
       arr[x].innerHTML = "new text";
     }
}

//calling the function with setTimeout to make sure the HTML is loaded
setTimeout(setText, 500);
HTML of the example
<div id ="demo">
  <p>some text</p>
  <p>some other text</p>
</div>
Note: The code above changes the text of both paragraphs to
new text
by Valeri Tandilashvili
4 years ago
JavaScript
DOM
3
Pro tip: use ```triple backticks around text``` to write in code fences