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

151
Views
Mostrar solo una cantidad específica de Elementos en un documento

Estoy creando una entrada de búsqueda que muestra una lista de resultados a medida que el usuario ingresa texto. Los resultados se llaman desde una base de datos JSON, que luego toma cierta información y la coloca como texto dentro de un elemento de anclaje. Estoy tratando de mostrar solo seis de estos resultados a la vez, y me preguntaba si había una manera de poner un límite a la cantidad de un determinado elemento que se puede mostrar y no invalida la variable i que ya tengo. ¿establecer? Gracias

Mi código:

 for (let i=0; i < results.length; i++) { var div = document.getElementById('dropdown'); var link = document.createElement('a'); var locDot = document.createElement('img'); var linkT = document.createElement('h1'); var linkV = document.createElement('p'); link.setAttribute('href', 'NTS_TAXI_PLACEMENT.html'); link.setAttribute('class', 'link'); link.setAttribute('id', `link${i}`); locDot.setAttribute('src', 'locationDot.png'); locDot.setAttribute('class', 'locationDot'); linkT.setAttribute('class', 'address'); linkV.setAttribute('class', 'city'); linkT.textContent = (`${results[i].title}`); linkV.textContent = (`${results[i].vicinity}`); div.appendChild(link); link.appendChild(locDot); link.appendChild(linkT); link.appendChild(linkV); var linkAmount = div.getElementsByTagName('a'); var linkDisplay = linkAmount[i].style.display; document.getElementById('test').innerHTML = linkDisplay; function filterFunction() { var i, input, inputStr, div, a; input = document.getElementById('searchInput'); inputStr = input.value.toUpperCase(); div = document.getElementById('dropdown'); a = document.getElementsByTagName('a'); for (i=0; i < results.length; i++) { txtValue = a[i].textContent; if (txtValue.toUpperCase().indexOf(inputStr) > -1) { a[i].style.display = ""; } else { a[i].style.display = "none"; } } } }
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!