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

117
Views
Haga clic en los botones en un sitio web con javascript basado en su clase y su hijo

¿Cómo puedo presionar todos los botones en una página dado el código html a continuación?

Quiero obtener el nombre del botón, y si el valor secundario coincide con el favorite_border para presionar automáticamente el botón.

 <button type="button" class="UnstyledButtonreact__UnstyledButton-sc-ty1bh0-0 btgkrL"><i size="20" aria-label="Favorite" value="favorite_border" class="Iconreact__Icon-sc-1gugx8q-0 FavoriteIconreact__StyledIcon-sc-289aae-0 irmnIh fNbWaJ material-icons">favorite</i></button>

Hasta ahora, se me ocurrió el siguiente código javascript, pero el problema es que para otros botones también se presionan, lo que interrumpe el flujo y me redirige a una página separada.

 var buttons = document.getElementsByClassName('UnstyledButtonreact__UnstyledButton-sc-ty1bh0-0 btgkrL'); for(var i = 0; i < buttons.length; i++) buttons[i].click();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Después de algunas búsquedas más, descubrí la respuesta yo mismo. El código final es:

 var buttons = document.getElementsByClassName('UnstyledButtonreact__UnstyledButton-sc-ty1bh0-0 btgkrL'); for(var i = 0; i < buttons.length; i++) var btn = buttons[i]; var child = btn.firstChild; if (child.innerHTML == "favorite_border") { buttons[i].click(); }
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!