<div class="codetitle"> <span><a style="CURSOR: pointer" data="91955" class="copybut" id="copybut91955" onclick="doCopy('code91955')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code91955"> <br><select id="cityList"><select><select id> <br> <option value="0">第0個</option> <br></select> <br><br><script> <BR> <BR><BR><script> <BR> <BR><BR><script> <BR> '); <BR> // 透過物件加入option <BR> selectId.add(new Option("第一個","1")) <BR> add selectId.com(new Option("第二個" 2")) <BR> // 透過id加入option <BR> selectId.add(new Option("第三個","3")) <BR> selectId.add(newion(new). "4")) <BR> // 透過id新增方式(也可透過物件新增方式) <BR> selectId.onchange = function(){ < selectObj .value); <BR> alert(selectObj.options[selectObj.selectedIndex].text); <BR> .value); <BR> alert(selectId.options [selectId.selectedIndex].text); <BR> // 也可透過this取得value與text <BR> dex].text); <BR> }; </script></select></select> </div>