mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-04-18 23:41:17 -04:00
fix: checkbox works now
This commit is contained in:
parent
f801569353
commit
b733a24ee3
1 changed files with 2 additions and 5 deletions
|
@ -48,7 +48,6 @@ function displayBooks(books) {
|
|||
const readBtn = document.createElement('button');
|
||||
const readBtnFlag = element.read ? "read" : "not read";
|
||||
const readBtnColor = element.read ? "green-btn-color" : "red-btn-color";
|
||||
console.log(readBtnColor, element.read, readBtnFlag);
|
||||
readBtn.classList.add('btn','read-btn',readBtnColor);
|
||||
|
||||
readBtn.textContent = readBtnFlag;
|
||||
|
@ -89,15 +88,13 @@ booksDiv.addEventListener('click', event => {
|
|||
submitButton.addEventListener('click', event => {
|
||||
const author = document.querySelector('#author').value;
|
||||
const title = document.querySelector('#title').value;
|
||||
const readBtn = document.querySelector('#read-button').value;
|
||||
const bookIsRead = readBtn === 'on' ? true : false;
|
||||
const readBtn = document.querySelector('#read-button').checked;
|
||||
|
||||
if (author === "" || title === "") {
|
||||
return
|
||||
}
|
||||
|
||||
// create book object
|
||||
const newBook = new Book(title, author, bookIsRead);
|
||||
const newBook = new Book(title, author, readBtn);
|
||||
|
||||
addBookToLibrary(newBook);
|
||||
displayBooks(myLibrary);
|
||||
|
|
Loading…
Add table
Reference in a new issue