Skip to content

Commit d8c315e

Browse files
committed
clear form fields after adding a book
1 parent bd070c0 commit d8c315e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

debugging/book-library/script.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function submit() {
4343
return false;
4444
}
4545

46-
// create and add the book
4746
const book = new Book(
4847
title.value.trim(),
4948
author.value.trim(),
@@ -52,9 +51,15 @@ function submit() {
5251
);
5352
myLibrary.push(book);
5453
render();
54+
55+
56+
title.value = "";
57+
author.value = "";
58+
pages.value = "";
59+
check.checked = false;
60+
5561
return true;
5662
}
57-
}
5863

5964
function Book(title, author, pages, check) {
6065
this.title = title;
@@ -70,7 +75,7 @@ function render() {
7075
for (let n = rowsNumber - 1; n > 0; n--) {
7176
table.deleteRow(n);
7277
}
73-
//insert updated row and cells
78+
7479
let length = myLibrary.length;
7580
for (let i = 0; i < length; i++) {
7681
let row = table.insertRow(1);
@@ -83,7 +88,7 @@ function render() {
8388
authorCell.textContent = myLibrary[i].author;
8489
pagesCell.textContent = String(myLibrary[i].pages);
8590

86-
//add and wait for action for read/unread button
91+
8792
let changeBut = document.createElement("button");
8893
changeBut.id = i;
8994
changeBut.className = "btn btn-success";

0 commit comments

Comments
 (0)