标签:
(function($) { $.fn.watch = function(callback) { return this.each(function() { //缓存以前的值 $.data(this, ‘originVal‘, $(this).val()); //event $(this).on(‘keyup paste‘, function() { var originVal = $(this, ‘originVal‘); var currentVal = $(this).val(); if (originVal !== currentVal) { $.data(this, ‘originVal‘, $(this).val()); callback(currentVal); } }); }); } })(jQuery);
$(document).ready(function() { $("#barcode").watch(function(value) { //... } }); });
标签:
原文地址:http://www.cnblogs.com/hehaiyang/p/4394495.html