accessing options of a select list - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Option

Description

accessing options of a select list

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      //  w  w  w  .jav a 2  s.c  o  m
      <title>Challenge Question</title>   
      <form action="get"> 
         <select name="questions"> 
            <option value="pet" name="pet">What is your pet's name?</option> 
         </select> 
      </form> 
      <!-- HTML5 style -->  
      <script type="text/javascript">
        console.log(document.forms[0].questions.options['pet']);
    
      </script>    
   </body>
</html>

Related Tutorials