Skip to content

Commit f29e2c0

Browse files
committed
alert
1 parent 714badb commit f29e2c0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

debugging/book-library/script.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,17 @@ function render() {
6666
row.insertCell(1).textContent = book.author;
6767
row.insertCell(2).textContent = book.pages;
6868

69-
// Read column (static)
70-
row.insertCell(3).textContent = book.check ? "Yes" : "No";
69+
// Read/unread button
70+
const wasReadCell = row.insertCell(3);
71+
const readToggleButton = document.createElement("button");
72+
readToggleButton.className = "btn btn-success";
73+
readToggleButton.textContent = book.check ? "Yes" : "No";
74+
wasReadCell.appendChild(readToggleButton);
75+
76+
readToggleButton.addEventListener("click", () => {
77+
myLibrary[i].check = !myLibrary[i].check;
78+
render();
79+
});
7180

7281
// Delete button
7382
const deleteCell = row.insertCell(4);

0 commit comments

Comments
 (0)