1
I’m not able to make a code work, where I create a function separately and call it whenever I want, but only changing the parameters. Javascript does not execute
function minhaFuncao(num1, num2) { //codigo } variavel.onclick = minhaFuncao(num1, num2);
How do I make it work? It only works if I write the function name, without the parameters, like:
variavel.onclick = minhaFuncao;
However I would like to pass parameters to the function after "onclick".
NOTE: Without declaring the function right after onclick, I want it to be declared earlier, just change the parameters.
That goes for
elemento.addEventListener
also.– Valdeir Psr