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

93
Visualizações
Clear icon event in text input on IE

that make up a currency converter, one with the number to be converted, the other receiving the converted number.

enter image description here

My question is: in IE in the input field, an X appears that if clicked allows the deletion of the value. I need to know how I do it (maybe with Javascript) at the click of the X I have to delete the result received in the other input field (see image).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There's no specific event handler available for the clear(X) icon. As a workaround, you can use the mouseup event to catch the change when you clear the input by clicking the clear(X) icon.

Sample code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    
</head>
<body>
    input1: <input type="text" id="ipt1" value="111" /><br />
    input2: <input type="text" id="ipt2" value="222" />
    <script>
            $("#ipt1").bind("mouseup", function (e) {
                var $input = $(this),
                    oldValue = $input.val();

                if (oldValue == "") return;

                // When this event is fired after clicking on the clear button
                // the value is not cleared yet. We have to wait for it.
                setTimeout(function () {
                    var newValue = $input.val();
                    if (newValue == "") {
                        $("#ipt2").val("");
                    }
                }, 1);
            });
    </script>
</body>
</html>

Result:

enter image description here

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