Skip to content

Instantly share code, notes, and snippets.

@calvez
Created December 14, 2017 13:01
Show Gist options
  • Save calvez/49508fcd201fe31c2fa4f8a133d17615 to your computer and use it in GitHub Desktop.
Save calvez/49508fcd201fe31c2fa4f8a133d17615 to your computer and use it in GitHub Desktop.
reload if value is changed https://stackoverflow.com/a/2885716
$('.valuefield').each(function() {
var elem = $(this);
// Save current value of element
elem.data('oldVal', elem.val());
// Look for changes in the value
elem.bind("propertychange change click keyup input paste", function(event){
// If value has changed...
console.log('value changed');
needcheck = 1;
if (elem.data('oldVal') != elem.val()) {
// Updated stored value
elem.data('oldVal', elem.val());
// Do action
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment