It has been awhile since I've worked in JavaScript and something just stumped me. I'm trying to call a function on an input change, but the function was running on page load only.
let textInput.document.getElementById('input');
textInput.addEventListener('input', myFunction());
Only runs on page load and doesn't seem to listen for the event at all. But
let textInput.document.getElementById('input');
textInput.addEventListener('input', function() {
myFunction();
});
works as expected. I have looked around trying to figure out why this is happening, but the docs that I've reviewed seem to indicate that I should be able to just call the myFunction() within the listener, without wrapping it in another function. Can someone explain to me what is going on here please?