From the course: JavaScript: Events

Unlock the full course today

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

Dealing with layers

Dealing with layers - JavaScript Tutorial

From the course: JavaScript: Events

Start my 1-month free trial

Dealing with layers

There's a little bit of a problem with our application and it's sort of hard to debug. The problem is with CSS layering and CSS layering is controlled by the z index attribute. So, if I grab any one of these and I drag them over and I click on any other one you'll see that this new one is now underneath this one. And really, every element that I pick up should be on top of the previous element. Just in case I want to rearrange things at one point. So, this is sort of a small problem, but it's something we need to deal with. The reason that's happening is, if we Inspect Element right here is, because every one of these elements originally has a z-index of 5. As soon as we start dragging them they get a Z index of 10. But because I drag these two elements, they both have the same Z index. And that's a problem because the one I dragged first is going to be on top of the one I dragged second. So in order to make sure our objects are always on top, we're going to have to write a function…

Contents