Skip to content

Commit f8a9819

Browse files
committed
lesson9 labojums
1 parent 5a2b513 commit f8a9819

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎app.js‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
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-
// delete books
4-
list.addEventListener('click', (e) => {
5-
if(e.target.className == 'delete'){
66
const li = e.target.parentElement;
7+
console.log('child element to remove:', li);
8+
console.log('parent element to remove child from:', li.parentElement);
79
li.parentNode.removeChild(li);
8-
}
10+
11+
});
12+
});
13+
14+
// prevent default behaviour
15+
16+
const link = document.querySelector('#page-banner a');
17+
18+
link.addEventListener('click', function(e){
19+
e.preventDefault();
20+
console.log('Navigation to', e.target.textContent, 'was prevented');
921
});

‎index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<div id="page-banner">
1212
<h1 class="title">Bookorama</h1>
1313
<p>Books for Ninjas</p>
14+
<a href="http://www.thenetninja.co.uk">Net Ninja Site</a>
1415
<form id="search-books">
1516
<input type="text" placeholder="Search books..." />
1617
</form>

0 commit comments

Comments
 (0)