I was trying to create a parameterized function using JS, I started code with a window.onload=()=>{},
and the syntax for my function is function name(arg){}
.
I want to call this function on a click event. so my statement goes btn.onclick=function_name(arg);
. but, the function gets called as soon as the page loads, without a click. What can i do to solve this problem?
window.onload = () => {
var btn .....
btn.onclick = func(arg..);
function func(arg){
}
}