how to change textContent in js
Get the text content of an element: var x = document. getElementById("myBtn"). ... Change the textual content of aelement with id="demo": getElementById("demo"). textContent = "Paragraph changed!"; Get all the textual content of an
- element with id="myList": getElementById("myList").
Here is what the above code is Doing:
1. The first line of code gets the element with the ID of “myBtn” and stores it in a variable called btn.
2. The second line of code gets the element with the ID of “demo” and stores it in a variable called demo.
3. The third line of code changes the text inside the element with the ID of “demo” to “Hello World!”