Any Help on why the function doesn't work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Any Help on why the function doesn't work

If i press the button the rect does not show

11th Jan 2019, 10:56 AM
Harshey's - avatar
4 Answers
+ 2
Because draw function is not global. It is local to that anonymous function you assigned to window.onload. Put that code in a script tag in html part(remove window.onload) or Use addEventListener.
11th Jan 2019, 11:22 AM
Prathamesh Sawant
Prathamesh Sawant - avatar
+ 8
11th Jan 2019, 11:24 AM
Bono - avatar
11th Jan 2019, 11:26 AM
Asgar Ali
Asgar Ali - avatar
+ 1
Thanks for the help
11th Jan 2019, 11:28 AM
Harshey's - avatar