Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda