How to call function in web | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to call function in web

HTML <div id="box" onclick=a()></div> JS window.onload = function() { function a(){ } } It make Error

5th Nov 2021, 3:56 AM
SorryPark
1 Answer
0
SorryPark If you are calling function from html elements then no need to write inside window.onload because function will call when you click. also function should be inside single quotes or double quotes in html elements. there should be onclick = 'a()'
5th Nov 2021, 5:22 AM
A͢J
A͢J - avatar