Skip to content

Commit 98182a6

Browse files
Shaun PellingShaun Pelling
authored andcommitted
refactor
1 parent d92c806 commit 98182a6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
const list = document.querySelector('#book-list ul');
1+
const listItems = document.querySelectorAll('#book-list ul li');
2+
3+
Array.from(listItems).forEach(function(item){
4+
item.addEventListener('click', (e) => {
25

3-
list.addEventListener('click', (e) => {
4-
if(e.target.className == 'delete'){
56
const li = e.target.parentElement;
67
console.log('child element to remove:', li);
78
console.log('parent element to remove child from:', li.parentElement);
89
li.parentNode.removeChild(li);
9-
}
10+
11+
});
1012
});
1113

1214
// prevent default behaviour

0 commit comments

Comments
 (0)