Skip to content

Commit 1de7803

Browse files
committed
update the render() function to delete just the the rows not the whole table
1 parent b16c7f2 commit 1de7803

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

debugging/book-library/script.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ function Book(title, author, pages, check) {
5858

5959
function render() {
6060
const table = document.getElementById("display");
61-
table.innerHTML = "";
61+
const tbody = table.querySelector("tbody");
62+
63+
// Clear existing rows
64+
tbody.innerHTML = "";
6265

6366
myLibrary.forEach((book, i) => {
6467
const row = table.insertRow();
@@ -88,5 +91,4 @@ function createDeleteCell(cell, index) {
8891
render();
8992
});
9093
cell.appendChild(deleteBtn);
91-
}
92-
94+
}

0 commit comments

Comments
 (0)