Javascript examples for DOM:Element children
Element children Property - Get the text of the third child element (index 2) of a <select> element:
<!DOCTYPE html> <html> <body> <select id="mySelect" size="4"> <option>Java</option> <option>SQL</option> <option>HTML</option> <option>CSS</option> </select>//w w w .j a va2 s . c o m <br><br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var c = document.getElementById("mySelect").children; document.getElementById("demo").innerHTML = c[2].text; } </script> </body> </html>