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

172
Views
seleccionando un elemento por un nombre de etiqueta y un nombre de clase

Estoy tratando de capturar etiquetas dentro de a encabezado con un nombre de clase conocido.

inspeccionar elemento:

 <h3 class="c-card__title"> <a href="https://www.springer.com/book/9783030873233" data-track="click" data-track-action="clicked article" data-track-label="article-0">SARS-CoV-2 Spike Protein Convergent Evolution </a> </h3>

mi código:

 var elements = document.getElementsByClassName("c-card__title").getElementsByTagName('a'); var vals = []; for(var i=0;typeof(elements[i])!='undefined';vals.push(elements[i++].getAttribute('href'))); for (var j = 0;typeof(vals[j])!='undefined'; ++j) { window.open(vals[j]);

Lo ejecuto en la consola del navegador pero me da el siguiente error:

 VM1065:4 Uncaught TypeError: document.getElementsByClassName(...).getElementsByTagName is not a function at <anonymous>:4:66
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

No puede usar el método getElementsByTagName después de getElementsByClassName , debe usar:

 document.querySelectorAll(".c-card__title > a");

echa un vistazo a esto

about 4 years ago · Santiago Gelvez 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!