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

182
Views
¿Cómo puedo agregar una clase, por ejemplo, 'activa' en uno de estos <li>, uno a la vez presionando las teclas arriba y abajo?

Intenté hacer un puntero al primer li y luego intenté navegar a través de él, pero no funcionó en mi caso: [esta es la imagen de mi elemento dom] [1]

 [1]: https://i.stack.imgur.com/f1uO6.png

Código:

 $(window).keyup(function(e) { console.log("Key Code: ", e.keyCode); var $currentParent = $('div[data-tree-model] li.active'); console.log("Current Parent", $currentParent); var $next; if (e.keyCode === 39 || e.keyCode === 37) { $currentParent[0].firstElementChild.click(); } else if (e.keyCode == 38) { $next = $currentParent.prev(); } else if (e.keyCode == 40) { $next = $currentParent.next(); } if ($next.length > 0) { $('div[data-tree-model] li ').removeClass('active'); $next.addClass('active'); } });
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!