+ 11
please who can help me?š¢
i have an error in java script which said: uncought typeError: cannot set property 'onclick' of null please who can help me for fixing itš this is the code https://code.sololearn.com/WverON6Tt9Yp/?ref=app
10 Answers
+ 11
wrap your entire javascript code with
window.onload = function(){ ....your code.... }
and leave it as onclick
this is caused by the javascript loading before the html
and because of that it looks for an element that has not been created yet, thus resulting in am error
+ 11
ĀÆ\_(ć)_/ĀÆ
+ 11
thanks for all
@Burey
@kamil
@Melik Melik Sonmez
+ 10
i changed it to onClick but nothing happenš
+ 10
@burey is absolutely right, that error occurs because of the order the computer reads your code, in the code playground the computer will read the js before your html, at that point your button isn't alive yet^^
+ 9
i really really thank you for your good answer
+ 8
yeah burey should get it ^^ I can't see new answers while I'm typing :/
+ 6
Well thanks I was wondering why that happened
+ 4
@burey given the answer and Kamil got approval :)
by the way i missed the load thing sorry for mis lead
+ 2
line 62 it should be onClick not onclick