Encontré un violín que registra cuando un campo de entrada cambia de valor. Sin embargo, también me gustaría registrar el nuevo valor. Probé todas las combinaciones que encontré en línea, pero no puedo hacer que funcione. aquí hay un violín: https://jsfiddle.net/XezmB/8/
índice
<input type="number" id="n" value="5" step=".5"/>guion
$(":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()); });Puede hacerlo cambiando la sexta línea de su código compartido.
De:
console.log("changed");A:
console.log("changed: ", $(this).val() );