Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- let liElement = document.getElementById('list');
- liElement.addEventListener('click', onListItemClick); // add only one eventListener on the parrent
- function onListItemClick(e) {
- if(e.target.tagName =='Li')
- .........
- .........
- }
- </script>
- or
- <script>
- document.addEventListener("click", e => {
- if (e.target.matches("li")) {
- console.log("Hi!")
- }
- });
- </script>
Add Comment
Please, Sign In to add comment