Javascript examples for DOM HTML Element:OptionGroup
Select and set an option within an optgroup
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <select name="dob_year"> <optgroup label="Morning"> <option value="1980">80</option> <option value="1981">81</option> <option value="1982">82</option> <option value="1983">83</option> </optgroup> </select> <script type="text/javascript"> document.querySelector('select').selectedIndex = 2; </script> </body>//w w w. j a va 2 s.c om </html>