How to make this work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
21st Sep 2021, 7:36 AM
EsaKurniawan
4 Answers
+ 2
mistakes : use myButton.addEventListener('click', runFunction); instead of myButton.addEventListener('click', runFunction()); brackets are the problem there is not need to give brackets runFunction() 2. if it shows runFunction is not defined try to write hole thing inside window.onload()=>{ //Your code } 3. if window.onload()=>{ } doesn't work try to use rupali solution
21st Sep 2021, 8:00 AM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Put your JS in script tag in Html section, it will work..
21st Sep 2021, 7:45 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
HrCoder Thanks, you give me my mistake, now it's work when i click button
21st Sep 2021, 8:12 AM
EsaKurniawan
0
Thanks, it's work now
21st Sep 2021, 7:55 AM
EsaKurniawan