![](/img/trans.png)
[英]Navigation animation using JS and SCSS, can you tell me where I'm going wrong?
[英]Can you tell me where i did wrong?
未捕獲的類型錯誤:planet.innerText 不是 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 代碼:```
So my js code isn't working in inspect it says that line 23 is not a function any solution to solve this?
錯誤信息非常清楚。 DOMElement.innerText
不是 function。 您應該將其用作屬性:
const planet = document.getElementById('redplanet');
planet.innerText = 'Hello world';
一個活生生的例子可以在這里找到:
https://jsfiddle.net/ga1ytz0j/
欲了解更多信息,請訪問:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText
它不是 function。 它是一種財產。
利用
planet.innerText = "Nothing to report";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.