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 an image
In the last movie we created an overlay and placed it on top of our window. What we want to do now is add the image on top of that overlay. To do that we're going to need to figure out where our large image is. Now if you take a look at my project you can see that I have a bunch of images here. When I click on one you see the overlay, but I need the big image right here. So my images have been very carefully saved in the same folder as the other images. So you could see here, here's the artwork section. So if I got a thumbnail called Baird Bellingham_tn.jpeg the large version of the image is the same name without the underscore thumbnail. First I need to find out he name of the item that I clicked on. That is stored in the event target. You can see right here that we were able to figure out the tag name of the image by querying the event target. And then the property tag name. So right over here. I want to create a new variable. I'm going to call it Image source. And I'm going to set…
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)
-