O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stacking Elements

$("img").on("click", function(){   $("img").css("z-index", 0);   $(this).css("z-index", 1); });

One of the coolest interactions that you can make with web pages is to rearrange elements on top of each other based on user interaction. The idea is that HTML elements can simply be stacked on top of each other like papers on a desk. At any time, you can reveal one of the hidden or partially hidden elements and place it on top of the others.

The z-index is a CSS property that specifies the position of an HTML element with respect to other elements not vertically or horizontally, but projected out toward the user. The element with the highest z-index is displayed on top of other elements when the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required