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

163
Visualizações
log $(this).val() in Jquery

I found a fiddle that logs when an input field changes value. However i would like to log the new value as well. I have tried all the combinations i found online, but cant get it to work. here is a fiddle: https://jsfiddle.net/XezmB/8/

index

<input type="number" id="n" value="5" step=".5"/>

script

    $(":input").bind('keyup change click', function (e) {
    if (! $(this).data("previousValue") || 
           $(this).data("previousValue") != $(this).val()
       )
   {
        console.log("changed");           
        $(this).data("previousValue", $(this).val());
   }
        
});


$(":input").each(function () {
    $(this).data("previousValue", $(this).val());
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can do that by changing the 6th line of your shared code.

From:

console.log("changed");           

To:

console.log("changed: ", $(this).val() );           
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