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 your favorite fruit: <select> <option id="myOption" value="apple">Apple</option> <option value="orange">Orange</option> </select> <p>Click the button to change the value of the apple option.</p> <button type="button" onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myOption").value = "newValue"; document.getElementById("demo").innerHTML = "The value of the value attribute of the 'apple' option has been changed from 'apple' to 'newValue'."; } </script> </body> </html>