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

112
Views
No puedo hacer que For loop se ejecute más de una vez

Tengo varios enlaces en mi página y una función que genera la vista previa de cada uno así:

Se supone que debe hacer un bucle y generar la vista previa para cada enlace, pero solo lo hace uno. ¿Porqué es eso?

 function parselinks() { var links = document.getElementsByClassName('linkprev'); for(var link of links) { if(link.innerHTML =='') { var data = {key: 'fe2964d7c80ef2b8f6ba046ae9e8c0a5', q: link.getAttribute('href') } fetch('https://api.linkpreview.net', { method: 'POST', mode: 'cors', body: JSON.stringify(data), }).then(res => res.json()).then(response => { var linktitle = response.title; var linkdesc = response.description; var linkimg = response.image; link.innerHTML = ` <span><img src="${linkimg}" alt=""></span> <h2>${linktitle}</h2> <br> <p>${linkdesc}</p> `; }) } } } parselinks();
 img {width:100px;} span { float: left; } span, h2, p { font-size: 15px; line-height: 80%; }
 <a href="https://yahoo.com" class="linkprev"></a> <a href="https://facebook.com" class="linkprev"></a> <a href="https://twitter.com" class="linkprev"></a> <a href="https://instagram.com" class="linkprev"></a>

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!