Link to home
Start Free TrialLog in
Avatar of TWB_Systems
TWB_Systems

asked on

How do I change the z-index by clicking anywhere other than on the element?

Here's what I am doing... I have an child element that has a z-index of -1 to begin with.  Once the parent is clicked, it changes the z-index of the child to 9999 to give it the feel of a pop-up.  Now when I click anywhere else on the page besides the parent or the child, I want the z-index of the child to go back to -1.  Can anyone provide help with this?

Thanks,
TWB
Avatar of DalHorinek
DalHorinek
Flag of Czechia image

I'm not sure if this will work, just guessing.

$(body).click( function() {
       $("#popup").css({ "z-index": -1});
});
Avatar of TWB_Systems
TWB_Systems

ASKER

I'm doing Javascript, not JQuery.
Avatar of Gurvinder Pal Singh
<body onclick="changeZIndex()" >
</body>

function changeZIndex()
{
   document.getElementById("popup").style.zindex = -1;
}
ASKER CERTIFIED SOLUTION
Avatar of Marbleman
Marbleman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just added a div with 100% width and 100% height that was one less than the current popup that way when I click that, I can send the new div to the back and the popup to hidden.