//需要在使用函数时传入event关键字
$('[name=lprice]').change(function(event){ $('[name=lprice]').validate({ event:event, }); })
在函数中获取
(function ( $ ) { var id=33; $.fn.validate=function(options){ // This is the easiest way to have default options. var settings = $.extend({ // These are the defaults. reg: /^\d+$/, msg:'请输入数字', //提示span的类型 noticeclass:'notice', event:'', }, options ); $val=this.val(); $val= $.trim($val); $matchra= $val.match(settings.reg); this.nextAll().filter('.'+settings.noticeclass).remove(); alert(settings.event.type) } }( jQuery ));