js弹出下拉列表中被选中的选项的索引用法代码
3672Js.Com2019-03-08 13:47 来源:未知 阅读:8983 关注度5
js弹出下拉列表中被选中的选项的索引用法代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>3672js教程(3672js.com)</title> <script> function getIndex(){ var x=document.getElementById("mySelect"); alert(x.selectedIndex); } </script> </head> <body> <form> 你喜欢的水果是: <select id="mySelect"> <option>苹果</option> <option>橙子</option> <option>菠萝</option> <option>香蕉</option> </select> <br><br> <input type="button" onclick="getIndex()" value="弹出选中项"> </form> </body> </html>本站文章为3672js教程网友分享投稿,版权归原作者,欢迎任何形式的转载,但请务必注明出处。同时文章内容如有侵犯了您的权益,请联系我们处理。
评论已被关闭