There is an input in a datalist that I am working with.
<input type="text" value="1" id="txtcount">
I am trying to obtain the new value of the input when the text changes.
I attempted to use the following code, but it did not work as expected.
<script>
//No global variables needed:)
$(document).ready(function(){
// Get the initial value
var $el = $('#txtcount');
$el.data('oldVal', $el.val() );
$el.change(function(){
// Store the new value
var $this = $(this);
var newValue = $this.data('newVal', $this.val());
})
.focus(function(){
// Get the value when the input gains focus
var oldValue = $(this).data('oldVal');
});
});