Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

279
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda