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

149
Views
lo viejo es oro. Pero, ¿hay alguna forma mejor de hacerlo?

Hola, tengo una lista desordenada. Quería recorrer los elementos li. Pero, por mi falta de conocimiento, no pude usar es6 para eso. Obtuve mi resultado usando for loop. Pero, quiero saber, ¿hay alguna manera mejor de hacerlo? Por favor hagamelo saber.

 <ul id="product-nav-ul"> <li id="first">All</li> <li id="second">Oranges</li> <li id="third">Fresh Meat</li> <li id="fourth">Vegetables</li> <li id="fifth">Fastfood</li> </ul> const productNavUl = document.getElementById('product-nav-ul'); let lis = productNavUl.children; console.log(productNavUl.children) console.log(lis.length) for(let i = 0; i<lis.length; i++){ console.log(lis[i].id) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto depende de lo que quieras hacer con los elementos li . Si solo desea recuperar la id , creo que el enfoque más "moderno" sería usar el map .

 const liIds = Array.from(productNavUl.children).map((li) => li.id)
about 4 years ago · Juan Pablo Isaza Report
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!