Help me please๐Ÿ™. I don't know what's wrong in my code. (I need both buttons to output the answer, not just one). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me please๐Ÿ™. I don't know what's wrong in my code. (I need both buttons to output the answer, not just one).

https://code.sololearn.com/W6JzNKPfEqAk/?ref=app

1st Apr 2023, 6:26 PM
ARTEM4IK
3 Answers
+ 6
You have defined two window.onload event handler functions. That's why it doesn't work. Combine content of the two functions' - move line 13 ~ 14 after line 6 (JS Tab)
1st Apr 2023, 6:44 PM
Ipang
+ 3
what Ipang said๐Ÿ‘: also, use let or const. function pon() { alert("you are right bro"); } function da() { alert("you are wrong try again"); } window.onload = function() { const btn = document.getElementById("but"); const bbb = document.getElementById("ok"); btn.onclick = pon; bbb.onclick = da; }
2nd Apr 2023, 3:04 AM
Bob_Li
Bob_Li - avatar
+ 2
Thank you very much!๐Ÿ‘
2nd Apr 2023, 7:11 AM
ARTEM4IK