Uncaught TypeError: planet.innerText is not a function
.addEventListener("click",function() {
let planet= document.getElementById("redplanet")
planet.innerText("Nothing to report");
planet.classList.remove("alert");
})
document.getElementById("greenplanet").classList.add("alert")
html code: “`
So my js code isn't working in inspect it says that line 23 is not a function any solution to solve this?
2
Answers
It is not a function. It is a property.
Use
The error message is quite clear.
DOMElement.innerText
is not a function. You are supposed to use it as a property:A live example can be found here:
https://jsfiddle.net/ga1ytz0j/
For more information, please visit:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText