Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Canāt update a divās style
Iām currently trying to change the divās background color whenever I press a button (which runs a function which in turn updates the window in question), but it refuses to update, saying the variable isnāt an object. I also canāt update the window to anything else, suggesting I made a baseline error. Iād greatly appreciate help or suggestions. https://code.sololearn.com/W1dspZEP80Pt/?ref=app
3 Respostas
+ 6
Hey Pxnt,
You have well written code, the only mistake you are making is using wrong object for doing DOM manipulation.
You have to use document object not the window object.
Window object contains methods like alert() and prompt() which does not have anything to do with DOM.
document object is responsible for doing all manipulation.
[FIXED]
https://code.sololearn.com/Wx12lW8QzzFj/?ref=app
+ 6
Pxnt Oh well haha
I did not see that you are actually defining the window variable.
I executed the code and got line number where error is occurring and saw that you're trying to do stuff with window object.
Happy Coding :D
+ 1
š« Rick Grimes thank you for your help! while you didnt point out exactly what I was looking for, i can now see my mistake - the variable window is already taken. Thank you!