I am trying to make a reset button clear all fields on my page. I have tried a few things which haven’t worked and I attach the latest version, which doesn’t work either.
Could someone point me in the right direction? Perhaps I need to wrap the whole thing in a form element and use the reset method?
The function code starts at line 100 in the script file…
Hello,
First I have to say that is an awesome app you have and secondly, it is not working properly because you are calling the function resetAll instead of passing it as a callback
resetButton.addEventListener("click", resetAll); // just remove the ()
In javascript the function is a callable object therefore can be passed around as value or invoked. For a event listener you want to pass it as value to be used later on as a call back. Is quite important to understand these two states of a function.
ok it’s working now. I was very confused by this initially, but I think I (sort of) get it now.
For any other beginners reading, I think I was confused as I was thinking of the callback as a specific value for some reason, rather than a ‘dormant’ function waiting to be called (that’s how it makes sense to me anyway).