Reputation: 225
I tried to swap the z-index of two div
elements.
The following code is my attempt to switch the two z-indices:
else if (pen_state == 1) {
var pen_zindex = $("#pen").css("z-index");
var curtain_zindex = $("#curtain").css("z-index");
if (curtain_zindex < pen_zindex) {
$("#curtain").css('z-index',pen_zindex);
$("#pen").css('z-index',curtain_zindex);
}
}
But whatever I do, I can not swap them.
Upvotes: 1
Views: 228
Reputation: 34080
The code you have seems to work for me when the elements are position:absolute
. See this example: http://jsfiddle.net/ChrisMBarr/AZXmU/
Upvotes: 2