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

149
Views
Desplazarse a un elemento al hacer clic en un botón

Quiero desplazarme a un elemento div cuando hago clic en un botón. Pero desafortunadamente el pergamino no funciona. Pero mi console.log()

Leí esto Desplazarse hasta la parte superior de la página después de renderizar en react.js y esto ¿Cómo desplazarse a un elemento?

 import React, { useEffect, useState, useRef } from 'react' function TeamOld() { const myRef = useRef(null) return ( <div> <button class="button is-primary is-outlined mr-4 mb-2" onClick={() => {myRef.current.scrollTo(0, 0); console.log("Test")}}>Click me</button> ... <div className="" style={{ width: "100%" }} ref={myRef}> </div> </div> ) } export default TeamOld
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La función que está buscando es scrollIntoView ( https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView ) scrollTo se usa para desplazar el elemento en sí (suponiendo que tenga barras de desplazamiento dentro de su div) .

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!