why is my calculator buttons not working ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why is my calculator buttons not working ?

I cant see any fault in the code ive got no errors and still when i click a buttons the numbers wont show up on the display https://code.sololearn.com/WPm2ff71tZ6j

29th Jan 2020, 12:38 PM
Lewis Casey
Lewis Casey - avatar
4 Answers
+ 2
The query selectors run before the HTML is loaded so they return empty lists. To fix this you could wrap all the stuff from 38 and later into window.addEventListener("load", () => { ... code ... }); so it is executed after the HTML is loaded.
29th Jan 2020, 12:50 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
Yep the code still doesn't work but at least the event listeners work. Btw. the reason why the guy in the video didn't need to wrap the code into the extra event listener is probably that he added the JS later in the HTML so it would also load after the rest of the HTML is loaded. On Sololearn sadly this doesn't work, in the JS tab at least. To fix the other bug maybe you need to change number.toString() to just number.
29th Jan 2020, 1:37 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
There are a couple lines where you need to replace innertext with innerText
29th Jan 2020, 1:49 PM
ODLNT
ODLNT - avatar
0
i wrapped it in that code its still not working, i watched a video to code this i will send it https://www.youtube.com/watch?v=j59qQ7YWLxw&t=1205s
29th Jan 2020, 1:22 PM
Lewis Casey
Lewis Casey - avatar