3 RĂ©ponses
+ 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");
11th Nov 2024, 9:23 PM
Bob_Li
Bob_Li - avatar
+ 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"; }
11th Nov 2024, 9:11 PM
Jerry Hobby
Jerry Hobby - avatar
+ 4
please stop tagging your next javascript questions as java ..
11th Nov 2024, 10:01 PM
zemiak