Javascript examples for DOM HTML Element:Option
Option value Property - Change the value of a specific option element:
<!DOCTYPE html> <html> <body> Select your favorite fruit: <select> <option id="myOption" value="a">Apple</option> <option value="orange">Orange</option> </select>//from w w w. ja v a2 s. com <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myOption").value = "newValue"; document.getElementById("demo").innerHTML = "changed"; } </script> </body> </html>