First of all, you can't use numbers as css selectors follow the
css grammar
If parent doesn't need a z-index, you can do:
What if you don't give a z-index to the parent div? But just give a negative z-index value to your child element, so it's hidden 'behind' the parent:
z-index: -1;
and whenever the popup is active, you will set a positive(higher z-index as the popup) z-index to the child element:
$('#div2').css('z-index', '2');
If your parent always needs a z-index(If this parent element needs to go over a other element with a z-index for example) then it's not possible:
It's not possible. As stated in this topic: z-index between Children and Parents
All child element z-index is calculated in respect to the parent
element. So the one of the 2 elements with the higher z-index will be
rendered above the other one and all its child elements.
You can however get the child element out of the parent element.
I would also suggest you to just increase the z-index by 1 when neccesary and not use big numbers as 99999. With the big numbers you would not know how much z-indexes you have used.