Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

327
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda