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

162
Vistas
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 Respuestas
Responde la pregunta

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 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