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

101
Visualizações
e.preventDefault() not working on onClick/onFocus event with an input

Trying to prevent the default behavior of clicking and focusing on an input. I understand that I can use CSS to prevent this (pointer-events: none). I am eventually trying to prevent clicking on input at certain caret positions.

Is there an explanation as to why e.preventDefault() isn't working in this situation?

import React from "react";

function InputText() {

  function handleClick(e) {
    e.preventDefault();
  }

  return (
    <input onClick={handleClick}></input>
  );
}

export default InputText;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Probably you can use the attribute Disable of input to prevent users from clicking and focusing. I think onclick just working well on stuff like buttons.

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