Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
How to disable an <a> tag in React after clicking it?

How can I disable the below anchor tag in React after it has been clicked? Like the onClick functionality is not working on the anchor tag.

<td align="left">
  <input
    type="file"
    accept=".csv,.xlsx,.xls"
    name="image"
    className="file-upload-input"
    onChange={(e: any) => {
      handleFileChange(e, data.c_id);
    }}
  />

  <a
    href="javascript:;"
    className="btn btn-secondary"
    style={{
      width: "125.62px",
      backgroundColor: "#0b5ed7",
      borderColor: "#0a58ca"
    }}
  >
    <img src={UploadIcon.default} />
    Upload
  </a>
</td>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

How about setting a conditional class on the anchor tag and disabling it through css? It would need a state variable to hold the disabled state. Code would look something like.

const [disabled, setDisabled] = useState();

<a
  href="javascript:;"
  onClick={() => {
  // setting the state on click
    setDisabled(true);
  }}
  // Adding class here
  className={`btn btn-secondary${disabled ? " disabled" : ""}`}
  style={{
    width: "125.62px",
    backgroundColor: "#0b5ed7",
    borderColor: "#0a58ca"
  }}
>
  <img src={""} />
  Upload
</a>

And the disabled class

.disabled {
  pointer-events: none;
  cursor: pointer;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

try to put a button within tag ,that way you can conditionally disable it.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda