0
Syntax error. WHERE!?
https://sololearn.com/compiler-playground/WiNiEZ378Aem/?ref=app
3 odpowiedzi
+ 5
Ethan
It is invalid to try to assign to the result of an optional chaining expression
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
Basically, it can't be on the left hand side of the "=" symbol.
But you can use the setProperty method instead.
document.getElementById("loadingScreen")?.style.setProperty("display","none");
+ 4
The error you're encountering with the line document.getElementById("loadingScreen")?.style.display = "none"; is likely due to the optional chaining operator (?.) being used in a way that is not supported in all environments or by the JavaScript engine you are using.
Replace this:
document.getElementById("loadingScreen")?.style.display = "none";
With this:
const loadingScreen = document.getElementById("loadingScreen");
if (loadingScreen) {
loadingScreen.style.display = "none";
}
+ 4
please stop tagging your next javascript questions as java ..