forked from iamshaunjp/JavaScript-DOM-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (15 loc) · 592 Bytes
/
app.js
File metadata and controls
21 lines (15 loc) · 592 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const listItems = document.querySelectorAll('#book-list ul li');
Array.from(listItems).forEach(function(item){
item.addEventListener('click', (e) => {
const li = e.target.parentElement;
console.log('child element to remove:', li);
console.log('parent element to remove child from:', li.parentElement);
li.parentNode.removeChild(li);
});
});
// prevent default behaviour
const link = document.querySelector('#page-banner a');
link.addEventListener('click', function(e){
e.preventDefault();
console.log('Navigation to', e.target.textContent, 'was prevented');
});