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.
You’re calling saveForm() immediately and passing its return value into addEventListener, so nothing runs on click. Change it to button. addEventListener('click', saveForm) (or () => saveForm() if you need to pass args).
:: Copyright KIRUPA 2024 //--