+ 5
Can you help me, please?
Hello everybody! I am trying to make a calculator, but when I give "Run", I get the following error: "Uncaught TypeError: document.getElementsById is not a function Line: 1" This is the code link: https://code.sololearn.com/W4yh8xggM0QZ/#js I have been searching the internet and, it says that it is by the type of browser I use (chrome), I provide it in Edge and in Mozilla And, it keeps giving me the same error. Can you please help me? I just start learning now.
10 Respostas
+ 6
Meritxell González Hey, check the corrected code :))
https://code.sololearn.com/W09hccYKUv8y/?ref=app
+ 6
Thanks you!! Arb Rahim Badsa and ChaoticDawg. I'm just begging to use JavaScript. Thank you a lot! Now I understand the problems 😂.
+ 3
It's document.getElementById()
Not Elements
+ 3
You need to wrap your JS code in window.onload = function () {...code...};
This is just due to SL injecting the JS tab into the head of the HTML prior to the DOM being initialized.
You also have several other errors in your JS code and some in your HTML.
I've fixed most of them now you just need to handle the logic etc of your calculator.
https://code.sololearn.com/WVvyCh17Uj7S/?ref=app
+ 3
https://code.sololearn.com/WtjV105y2lBO/?ref=app
Calculator use simple method
+ 2
Thanksss!!
+ 2
Here is the corrected code :))
https://code.sololearn.com/W39Ad0aOv3QY/?ref=app
+ 1
Now I get this error:
Uncaught TypeError: Cannot read property 'addEventListener' of null
Line: 1
what does it mean?
0
https://code.sololearn.com/WHgJVqP4RoB4/?ref=app
You can learn from here
0
Hii