<div class="codetitle"> <span><a style="CURSOR: pointer" data="36497" class="copybut" id="copybut36497" onclick="doCopy('code36497')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code36497"> <br><script> <BR>function clearOption(obj,e){ <BR>var currKey=0,e=e||event; <BR>currKey=e.keyCode||e.which||e.charCode; <BR>if(currKey == 8){ <BR>obj.options[0].text = ""; <BR>} <BR>} <BR>function writeSelect(obj,e){ <BR>var currKey=0,e=e||event; <BR>currKey=e.keyCode||e.which||e.charCode; <BR>obj.options[0].selected = "select"; <BR>if(currKey != 8){//这个地方是为了避免在firefox又出现令人厌烦的乱码,可以试试注释这句话,看看在firefox的效果 <BR>obj.options[0].text = obj.options[0].text + String.fromCharCode(currKey); <BR>} <BR>e.returnValue=false; <BR>return obj.options[0].text; <BR>} <BR>function ttt(){ <BR>var jg = document.getElementById("aa").options[document.getElementById("aa").selectedIndex].text; <BR>//当然也可以在前面的writeSelect函数里面同时设置options的value,这样的话,直接可以在该程序里面用value取出 <BR>jQuery("#aa").empty(); <BR>jQuery("#aa").append("<option value=''>"); <BR>} <br><br></script> <br> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="28211" class="copybut" id="copybut28211" onclick="doCopy('code28211')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code28211"> <br><select style="width:150px;z-index:-1" id="aa" name="selectHelpCode" onkeydown="clearOption(this,event)" onkeypress="writeSelect(this,event)"> <br><option value=""></option> <br><option value="11">11</option> <br><option value="22">22</option> <br><option value="33">33</option> <br></select> <br><input type="button" value="清除" onclick="ttt();"> <br> </div>