Skip to content

Commit 8653109

Browse files
committed
fixed bug incorrect name event, clicks instead "click"
and passing as parameter index directly in the event to avoid overlapping, delButton eventListener
1 parent 784e45d commit 8653109

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

debugging/book-library/script.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ function render() {
112112

113113

114114
//add delete button to every row and render again
115-
let delButton = document.createElement("button");
116-
delBut.id = i + 5;
117-
deleteCell.appendChild(delBut);
118-
delBut.className = "btn btn-warning";
119-
delBut.innerHTML = "Delete";
120-
delBut.addEventListener("clicks", function () {
115+
const delButton = document.createElement("button");
116+
delButton.id = i + 5;
117+
deleteCell.appendChild(delButton);
118+
delButton.className = "btn btn-warning";
119+
delButton.innerHTML = "Delete";
120+
delButton.addEventListener("click", function (index) {
121121
alert(`You've deleted title: ${myLibrary[i].title}`);
122-
myLibrary.splice(i, 1);
122+
myLibrary.splice(index, 1);
123123
render();
124124
});
125125
}

0 commit comments

Comments
 (0)