$.fn.observe = function(interval, callback) { return this.each(function() { var vm = (this.tagName == 'FORM') ? 'serialize' : 'getValue', lastValue = $(this)[vm](), self = this; setInterval(function() { var value = $(self)[vm](); if (value != lastValue) { callback(self, value); lastValue = value; } }, interval * 1000); }); };