<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(obje){ <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> <br> <br><option value="11">11</option> <br><option value="22">22</option> <br><option value=" 33">33</option> <br> <br><input type="button" value="清除" onclick="ttt();"> <br> </div>