<div class="codetitle"> <span><a style="CURSOR: pointer" data="36280" class="copybut" id="copybut36280" onclick="doCopy('code36280')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code36280"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br><html xmlns="http://www.w3.org/1999/xhtml"><br><head><br><title>autoComplete</title><br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br><style type="text/css"><br>.autoComplete {margin:8px;position:relative;float:left;}<br>.autoComplete input {width:200px;height:25px;margin:0;padding:0;line-height:25px;}<br>.autoComplete ul {z-index:-12;padding:0px;margin:0px;border:1px #333 solid;width:200px;background:white;display:none;position:absolute;left:0;top:28px;*margin-left:9px;*margin-top:2px;margin-top:1px;}<br>.autoComplete li {list-style:none;}<br>.autoComplete li a {display:block;color:#000;text-decoration:none;padding:1px 0 1px 5px;_width:97%;}<br>.autoComplete li a:hover {color:#000;background:#ccc;border:none;}<br></style><br><script type="text/javascript"><br>//<![CDATA[<BR>var getElementsByClassName = function (searchClass, node, tag) {/* 兼容各浏览器的选择class的方法;(:http://www.jb51.net,想了解更多请看这个地址) */<BR> node = node || document, tag = tag ? tag.toUpperCase() : "*";<BR> if(document.getElementsByClassName){/* 支持getElementsByClassName的浏览器 */<BR> var temp = node.getElementsByClassName(searchClass);<BR> if(tag=="*"){<BR> return temp;<BR> } else {<BR> var ret = new Array();<BR> for(var i=0; i<temp.length; i )<BR> if(temp[i].nodeName==tag)<BR> ret.push(temp[i]);<BR> return ret;<BR> }<BR> }else{/* 不支持getElementsByClassName的浏览器 */<BR> var classes = searchClass.split(" "),<BR> elements = (tag === "*" && node.all)? node.all : node.getElementsByTagName(tag),<BR> patterns = [], returnElements = [], current, match;<BR> var i = classes.length;<BR> while(--i >= 0)<br> patterns.push(new RegExp("(^|s)" classes[i] "(s|$)"));<br> var j = elements.length;<br> while(--j >= 0){<br> current = elements[j], match = false;<br> for(var k=0, kl=patterns.length; k<kl; k ){<BR> match = patterns[k].test(current.className);<BR> if(!match) break;<BR> }<BR> if(match) returnElements.push(current);<BR> }<BR> return returnElements;<BR> }<BR>};<BR>var addEvent=(function(){/* 用此函数添加事件防止事件覆盖 */<BR> if(document.addEventListener){<BR> return function(type, fn){ this.addEventListener(type, fn, false); };<BR> }else if(document.attachEvent){<BR> return function(type,fn){<BR> this.attachEvent(on type, function () {<BR> return fn.call(this, window.event);/* 兼容IE */<BR> });<BR> };<BR> }<BR>})();<BR>;(function(window){<BR>/* Plug-in start*/<BR>var autoComplete=function(o){<BR> var handler=(function(){<BR> var handler =function(e,o){ return new handler.prototype.init(e,o); };/* Create a corresponding object for each selected dom, so that it can be used easily when selecting multiple doms */<BR> handler.prototype={<BR> e:null, o:null, timer:null, show:0, input:null, popup:null,<BR> init:function(e,o){/ * Set the initial object*/<BR> this.e=e, this.o=o,<BR> this.input=this.e.getElementsByTagName(this.o.input)[0],<BR> this.popup =this.e.getElementsByTagName(this.o.popup)[0],<BR> this.initEvent();/* Initialize various events*/<BR> },<BR> :match(quickExpr,value, source){/* Generate prompt*/<BR> var li = null;<BR> null ){<BR> li = document.createElement(li);<BR> li.innerHTML = <a href="javascript:;"> source[i] </a>;<br> This.popup .appendChild(li);<br> This.popup.style.display=block;<br> else<br> this.popup.style.display=none;<br> },<br> </div>