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

145
Views
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
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!