+ 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.

11th May 2020, 11:53 AM
Meritxell GonzĂĄlez
Meritxell GonzĂĄlez - avatar
10 Answers
11th May 2020, 12:34 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 6
Thanks you!! Arb Rahim Badsa and ChaoticDawg. I'm just begging to use JavaScript. Thank you a lot! Now I understand the problems 😂.
11th May 2020, 12:51 PM
Meritxell GonzĂĄlez
Meritxell GonzĂĄlez - avatar
+ 3
It's document.getElementById() Not Elements
11th May 2020, 12:10 PM
ChaoticDawg
ChaoticDawg - avatar
+ 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
11th May 2020, 12:38 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
https://code.sololearn.com/WtjV105y2lBO/?ref=app Calculator use simple method
13th May 2020, 9:19 AM
Jahid Hasan
Jahid Hasan - avatar
+ 2
Thanksss!!
11th May 2020, 12:11 PM
Meritxell GonzĂĄlez
Meritxell GonzĂĄlez - avatar
+ 2
12th May 2020, 5:44 AM
Rahman Rezaie đŸ‡ŠđŸ‡«
Rahman Rezaie đŸ‡ŠđŸ‡« - avatar
+ 1
Now I get this error: Uncaught TypeError: Cannot read property 'addEventListener' of null Line: 1 what does it mean?
11th May 2020, 12:14 PM
Meritxell GonzĂĄlez
Meritxell GonzĂĄlez - avatar
13th May 2020, 6:37 AM
RISHABH
RISHABH - avatar
0
Hii
13th May 2020, 8:37 AM
subbu 😘