| 范文 | 
		     本文实例讲述了js显示下拉列表框内全部元素的方法。分享给大家供大家参考。具体如下:     下面的js代码可以通过alert框显示指定下拉列表的全部元素     <!doctype html>     <html>     <head>     <script>     function getoptions()     {     var x=document.getelementbyid(myselect);     var txt=all options: ;     var i;     for (i=0;i<x.length;i++)     {     txt=txt + \n + x.options[i].text;     }     alert(txt);     }     </script>     </head>     <body>     <form>     select your favorite fruit:     <select id=myselect>     <option>apple</option>     <option>orange</option>     <option>pineapple</option>     <option>banana</option>     </select>     <br><br>     <input type=button onclick=getoptions()     value=output all options>     </form>     </body>     </html>
  |