源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function disable(){ document.getElementById("mySelect").disabled=true; } function enable(){ document.getElementById("mySelect").disabled=false; } </script> </head> <body> <form> <select id="mySelect"> <option>蘋果</option> <option>梨子</option> <option>香蕉</option> <option>橙子</option> </select> <br><br> <input type="button" onclick="disable()" value="禁用列表"> <input type="button" onclick="enable()" value="啟用列表"> </form> </body> </html>
運行結果