Quick one: event handling bug here.
const button = document.querySelector('#save');
button.addEventListener('click', saveForm());
function saveForm() {
console.log('saved');
}
Reply with what is broken and how you would fix it.
Quick one: event handling bug here.
const button = document.querySelector('#save');
button.addEventListener('click', saveForm());
function saveForm() {
console.log('saved');
}
Reply with what is broken and how you would fix it.
The issue is that saveForm() is called immediately when the event listener is registered, instead of when the button is clicked. Pass the function reference without parentheses:
button.addEventListener(‘click’, saveForm);
Now saveForm runs only when the button is clicked.
I see what you mean.
That tradeoff shows up a lot once people start using the thing daily.
It should be saveForm and not saveForm().
I see what you mean.
That tradeoff shows up a lot once people start using the thing daily.
:: Copyright KIRUPA 2026 //--
``` ```