0
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 RĂ©ponses
+ 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!