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

229
Views
¿Cómo controlar la tecla de tabulación entre los botones en reaccionar, javascript?

Tengo 3 botones Cancelar, Atrás, Continuar respectivamente. cuando presione la tecla de tabulación que debería ir a los botones Continuar, Cancelar, Atrás.
¿Cómo podemos hacer eso en React, Javascript? Consulte https://codesandbox.io/s/crazy-ishizaka-cnr5k?file=/src/App.js

 export default function App() { return ( <div className="App"> <button tabIndex="2">submit 1</button> <button tabIndex="3">submit 2</button> <button tabIndex="1">submit 3</button> </div> ); }

este código anterior no funciona como esperaba. Sugiera una solución eficiente para esto.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo primero sobre tabIndex es que actuaría de forma extraña si desea saltar directamente a los botones y entradas. Después de algunas investigaciones sobre su problema, descubrí que debe hacer dos cosas:

  1. El primero es que debe agregar all:initial a la raíz en el estilo de su proyecto. por ejemplo, en su caso de que el proyecto sea React, debe agregar esto a index.html y cambiarlo así:

 <!DOCTYPE html> <html lang="en" style="all: initial;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> <title>React App</title> </head> <body> <noscript> You need to enable JavaScript to run this app. </noscript> <div id="root"></div> </body> </html>

Cambié la etiqueta HTML y agregué el estilo en la segunda línea.

  1. Lo segundo que debe hacer es considerar un lado para los botones que el índice pueda atravesar primero y luego pueda seguir su orden. en mi caso, he agregado esto: (y sé que la primera pestaña no haría nada)

 export default function App() { return ( <div className="App" tabIndex={1}> <button tabIndex={3}>submit 1</button> <button tabIndex={4}>submit 2</button> <button tabIndex={2}>submit 3</button> </div> );

He bifurcado tu codesandbox y puedes acceder a él con este enlace: https://codesandbox.io/s/dawn-hill-1br66?file=/src/App.js

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!