Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE HTML> <html> <head> <title>Title of the Document</title> </head> <body> <select id="select"> <option value="green">Green</option> <option value="red">Red</option> <option value="blue">Blue</option> </select> <script> // all three lines do the same thing select.options[2].selected = true; select.selectedIndex = 2; select.value = 'red'; </script> </body> </html>