From the course: JavaScript: Enhancing the DOM

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Creating and styling an overlay with JavaScript

Creating and styling an overlay with JavaScript

From the course: JavaScript: Enhancing the DOM

Start my 1-month free trial

Creating and styling an overlay with JavaScript

So, in this movie I want to show you how to create an overlay. We're going to use a lot of things that we already used in previous movies. So, first off, I'll remove this console lock command. And what I want to do is create a variable and call it myoverlay. And in here I want to create a new element. So, I'm going to use the Create Element method. And create a new div in our document. So, just so that it's easier to target, I want to make this overlay have an id of overlay. I can do that by just using the dot notation and pass an empty attribute. In this case the id that I want to change and then I want to add this to the current document so, I'll just add it to the body tag and use the Append Child method. And pass along my overlay so, what this'll do is once you click on an image its going to add this overlay to the end of the bodytag, so let's go ahead and go into our code. So, here we are in the artist page. And I'm going to scroll down and click on one of these items. It doesn't…

Contents