From the course: JavaScript: Enhancing the DOM (2013)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Adding a bubbling event listener
From the course: JavaScript: Enhancing the DOM (2013)
Adding a bubbling event listener
So let's go ahead and work on this project. Right now I'm on the artist's page of this website. And what I want to do is target this section right here with the art from each artist. I need to make sure that I create a node that targets this area right here. And then add a listener for that node that checks for a click. If one of these images is clicked then we're going to execute some code. So I'm going to switch over to my code and show you that this is a very simple list right here, that has image text inside each list item. So right now my java script code is completely empty. First I will start off by creating a sell executing function. So just protect any of our local variables from anything else running in our page. So start by creating a variable called myNode and then I'm going to set it to document.querySelector and I'm going to target a section in my page. Now what do I need to target? Let's go back into this page and pull up the console and what I want to do is target this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What we'll build2m 16s
-
(Locked)
Adding a bubbling event listener4m 11s
-
(Locked)
Creating and styling an overlay with JavaScript4m 39s
-
(Locked)
Adding an image3m 48s
-
(Locked)
Resizing images in the DOM2m 59s
-
(Locked)
Centering an image2m 36s
-
(Locked)
Handling clicks1m 29s
-
(Locked)
Adjusting for scrolling1m 36s
-
Detecting and adjusting for a window resize2m 40s
-
(Locked)
-