I have an unordered list.
<style>
#button1 { position:relative; z-index: 3; }
#button2 { position:relative; z-index: 2; }
#button3 { position:relative; z-index: 1; }
</style>
<ul>
<li id="button1">Button 1</li>
<li id="button2">Button 2</li>
<li id="button3">Button 3</li>
</ul>
I am currently using css to give each id a different z-index so that one button is slightly on top of the next. What I want to do is to use jQuery to add a class that add's a much higher z-index to whatever button was clicked such as '999' to ensure that it will be on top of the other two buttons. I can't figure out how to add an active class to the currently clicked <li>
while removing the active class from whatever button currently has it set. I don't know how to make jQuery figure out which of the other two <li>
's has the active class set before the new button is pushed. How would I go about doing that?
Also I am not sure if adding a class will solve the problem since I am already setting the z-index by targeting the <li>
's id. Maybe I would need to affect the inline css for the currently pushed button so it overrides the id's css, and also have it check to see which of the other two has the inline css z-index set to '999' so it can remove their inline css and have a larger z-index than the other two buttons and appear on top?