Skip to content

Instantly share code, notes, and snippets.

@kacpak
Last active April 26, 2016 21:01
Show Gist options
  • Save kacpak/69b5f58a316b9d17cbb7e6b3874f2d8b to your computer and use it in GitHub Desktop.
Save kacpak/69b5f58a316b9d17cbb7e6b3874f2d8b to your computer and use it in GitHub Desktop.
jQuery on value changed
jQuery.fn.textChange = function(callback) {
return this.each(function() {
var lastentry = '';
$(this).keyup(function(event) {
var value = $(this).val();
if (value != lastentry) {
if (typeof callback == 'function')
callback.call(this);
}
lastentry = value;
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment