Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <select id="pets" size="3"> <option>Cat</option> <option>Dog</option> <option>Horse</option> </select> <p>Click the button to disable the third option (index 2) in the dropdown list.</p> <button onclick="myFunction()">Disable Option</button> <script> function myFunction() { var x = document.getElementById("pets").options[2].disabled = true; } </script> </body> </html>