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

Adding a bubbling event listener

From the course: JavaScript: Enhancing the DOM (2013)

Start my 1-month free trial

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…

Contents