This file contains hidden or 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
| let ul = document.querySelector("#book-list ul"); | |
| ul.addEventListener('click', function(e){ | |
| if( e.target.className == 'delete'){ | |
| const clickedButtonParentElement = e.target.parentElement; | |
| ul.removeChild( clickedButtonParentElement ) | |
| } | |
| }) | |
| // PREVENT DEFAULT BEHAVIOUR AND EXTRACT THE VALUE OF WHAT HAS BEEN TYPED |
This file contains hidden or 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
| <div class= "parentElement">parentElement | |
| <div class = "childElement">childElement | |
| </div> | |
| </div> | |
| <script> | |
| let parentElement = document.querySelector('.parentElement'); | |
| parentElement.addEventListener( 'click', function(){ | |
| console.log('am a parent element') | |
| }); |
This file contains hidden or 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
| // delete a book | |
| let deleteBtns = document.querySelectorAll('#book-list .delete'); | |
| Array.from (deleteBtns) | |
| .forEach( deleteBtn => { | |
| deleteBtn.addEventListener('click', function(e){ | |
| const clickedButtonParent = e.target.parentElement; | |
| clickedButtonParent.parentNode.removeChild(clickedButtonParent); | |
| // And thats it. Go ahead and try it out | |
| }) |
This file contains hidden or 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
| body{ | |
| font-family: Tahoma; | |
| color: #444; | |
| letter-spacing: 1px; | |
| } | |
| h1, h2{ | |
| font-weight: normal; | |
| } |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <link href="styles.css" rel="stylesheet" /> | |
| <title>JavaScript DOM Tutorials</title> | |
| </head> | |
| <body> | |
| <div id="wrapper"> | |
| <header> |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>DOM</title> | |
| </head> | |
| <body> | |
| <div id="firstDiv"> |
This file contains hidden or 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
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <p></P> | |
| </body> | |
| </html> |
This file contains hidden or 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
| // destructure | |
| let { name, school } = details; | |
| console.log( name ); //Chidera | |
| console.log( school ) //fupre |
This file contains hidden or 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
| let name = details.name; | |
| let school = details.school; | |
| console.log( name ); //Chidera | |
| console.log( school ) //fupre |
This file contains hidden or 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
| let [ , , captain ] = players; | |
| console.log( captain ) // captain |