-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const input = document.querySelector('#favchap'); | ||
const button = document.querySelector('#addChapterButton'); | ||
const list = document.querySelector('#list'); | ||
|
||
button.addEventListener('click', function() { | ||
if (input.value.trim() !== '') { | ||
const li = document.createElement('li'); | ||
const deleteButton = document.createElement('button'); | ||
|
||
li.textContent = input.value; | ||
deleteButton.textContent = '❌'; | ||
|
||
li.append(deleteButton); | ||
list.append(li); | ||
|
||
deleteButton.addEventListener('click', function() { | ||
list.removeChild(li); | ||
input.focus(); | ||
}); | ||
|
||
input.value = ''; | ||
} else { | ||
// Provide a message or alert the user to enter a book and chapter. | ||
// You can use alert or some other method to communicate this to the user. | ||
// For example: | ||
// alert('Please enter a book and chapter.'); | ||
input.focus(); | ||
} | ||
}); | ||
}); |
File renamed without changes.