下面是jQuery插件: 代码如下: ;(function($){ /* Plugin */ $.fn.autoComplete=function(o){ if(o.ajax) o.ajax=$.extend({ url:'', dataType:'json', async:true }, o.ajax||{}); o.elemCSS=$.extend({ focus:{'color':'#f00'}, blur:{'color':'#000'} }, o.elemCSS||{}); o=$.extend({ source:null,/* privide an array for match */ ajax:{},/* provide an ajax conditions, if source is exist this parameter is invalid */ input:'input',/* provide the selector of input box */ popup:'ul',/* provide the selector of popup box, it must be a ul element of html */ elemCSS:{}/* provide the focus and blur css objects of items in the popup box */ },o||{}); var handler=(function(){ var handler=function(e,o){ return new handler.prototype.init(e,o); }; handler.prototype={ e:null, o:null, timer:null, show:0, $input:null, $popup:null, init:function(e,o){ this.e=e; this.o=o; this.$input=$(this.o.input,this.e); this.$popup=$(this.o.popup,this.e); this.initEvent(); }, match:function(quickExpr,value,source){ for(var i in source){ if( value.length>0 && quickExpr.exec(source[i])!=null ) this.$popup.append('