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

147
Vistas
Traversing focus on right and left arrow keys

First press the tab key, the first link will be highlighted then press the right arrow keys to see the focus jumping to next level navigation traversing ahead, similar way once I click the left arrow key focus has to come back.

In the following code keycode 39 is working fine. Can someone help me once i press keycode 37 the focus has to go back.

Full html code in fiddle.

<script>
$('.we-mega-menu-ul>.dropdown-menu a').keydown(function (e) {
if ([37, 39].indexOf(e.keyCode) === -1) {
    return;
}
var link = $(this);
switch (e.keyCode) {
    case 37: // left arrow key
    // Make sure to stop event bubbling
    e.preventDefault();
    e.stopPropagation();
    if (link.parent('li').find('li').filter(':visible').first().length === 0) {
        link.parent('li').find('li').filter(':visible').last().find('a').first().focus();
    }
    else {
        link.parent('li').find('li').filter(':visible').first().find('a').first().focus();
    }
    break;
    case 39: // right arrow key
    e.preventDefault();
    e.stopPropagation();
    if (link.parent('li').find('li').filter(':visible').first().length === 0) {
        link.parent('li').find('li').filter(':visible').last().find('a').first().focus();
    }
    else {
        link.parent('li').find('li').filter(':visible').first().find('a').first().focus();
    }
    break;
}
});
</script>
about 4 years ago · Juan Pablo Isaza
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