W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript"> function alertDefaultDisabled() { var x=document.getElementById("mySelect").selectedIndex; var y=document.getElementsByTagName("option"); alert("Is " + y[x].text + " disabled by default? " + y[x].disabled); } </script> </head> <body> <form> Select your favorite fruit: <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option disabled="disabled">Pineapple</option> <option>Banana</option> </select> <br /> <br /> <input type="button" onclick="alertDefaultDisabled()" value="Is the chosen fruit disabled by default?"> </form> </body> </html>