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

235
Views
React JS scrollLeft no funciona con el selector de nombre de clase

Tengo contenedor con desplazamiento horizontal. Cuando hago clic en un botón, quiero desplazarme hasta el final del contenedor (totalmente hacia la derecha).

Mi función al hacer clic:

 const scrollToEnd = () => { var parent = document.getElementsByClassName('custom-class-name'); for(var i=0;i<parent.length;i++) { var child = parent[i].getElementsByClassName('my-container'); child[0].scrollLeft = 100; } }

En mi función de retorno

 <Button onClick={(e) => { anotherFunction(); scrollToEnd(); }} />

No pasa nada cuando hago clic en el botón. Probé para ver si estoy seleccionando el elemento correcto usando un estilo:

child[0].style.color='red';

Esto funciona. El color de estilo rojo se agrega a .my-container pero scrollLeft no funciona.

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!