I’m trying to call a function in the .on() method with a parameter but it doesn’t seem to work. Many thanks!
$(".column0").on("click", fillBoard(0))
I’m trying to call a function in the .on() method with a parameter but it doesn’t seem to work. Many thanks!
$(".column0").on("click", fillBoard(0))
Invoke fillBoard(0) in an anonymous or arrow function.
$(".column0").on("click", () => fillBoard(0));
As it is you are invoking the function and inserting the result where the handler should go. So if you want to pass an argument you need to invoke the function with the argument inside another function that becomes the handler.