1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<div id="app"> <div style="display:flex;"> <button>Test</button> old </div> </div> <script> function go() { // Get text node with "old" in it. const node = document.getElementById('app').firstElementChild.lastChild; // Change to "new". node.textContent = 'new'; } </script>