Skip to content

Commit 1966aac

Browse files
committed
fix(delete): correct variable name and event type so delete button works
1 parent feee606 commit 1966aac

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

debugging/book-library/script.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ function render() {
101101
render();
102102
});
103103

104-
//add delete button to every row and render again
105-
let delButton = document.createElement("button");
106-
delBut.id = i + 5;
107-
deleteCell.appendChild(delBut);
104+
const delBut = document.createElement("button");
105+
delBut.id = String(i + 5);
108106
delBut.className = "btn btn-warning";
109-
delBut.innerHTML = "Delete";
110-
delBut.addEventListener("clicks", function () {
107+
delBut.textContent = "Delete";
108+
delBut.addEventListener("click", function () {
111109
alert(`You've deleted title: ${myLibrary[i].title}`);
112110
myLibrary.splice(i, 1);
113111
render();
114-
});
112+
});
113+
deleteCell.appendChild(delBut);
115114
}
116115
}
116+

0 commit comments

Comments
 (0)