I'm having a problem with preventDefault()
on an event type='submit'
.
let submitBookButton = document.querySelector('.submitBook');
submitBookButton.addEventListener('submit', (event) => {
event.preventDefault();
let newBook = new Book(titleInput.value, authorInput.value, pagesInput.value, readInput.checked);
myLibrary.push(newBook);
console.log(myLibrary);
});
In HTML I also have button type='submit'
.
I've tried changing everything I can think of but it still reloads the page on click.