Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
Multiple negative z-index in dropdown menu

I have a dropdown menu with 4 menu categories. One, Two, Three & Four. Each category have a negative z-index command.

One (z-index-1) Two (z-index-2) Three (z-index-2) Four (z-index-2)

That way, zindex-1 is always in front (ΟΝΕ).

If I press menu Two, I want it to become z-index -1 and the rest to change automatically to -2 etc. i.e

One (z-index-2) Two (z-index-1) Three (z-index-2) Four (z-index-2)

I wonder , is there a better way to write this code? Thanks

enter image description here

$('.one').css({
'position': 'absolute',
'z-index': '-1'
});

$('.two').css({
'position': 'absolute',
'z-index': '-2'
});

$('.three').css({
'position': 'absolute',
'z-index': '-2'
});

$('.four').css({
'position': 'absolute',
'z-index': '-2'
});

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

for starters -

$('.one,.two,.three,.four').click(function() { 
   $('.one,.two,.three,.four').css({position: 'absolute', 'z-index': '-2'});
   $(this).css('z-index', '-1'); 
})

But if you added your html, and actual purpose in doing that, I believe the answer will be much different.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!