• js select 用法


    <html>
    <body>
        <select id="osel">
        </select>

        <script language="javascript" type="text/javascript">
    <!--
            var osel = document.getElementById("osel");
    //        var newarr = [
    //                                 ['A', 'B'],
    //                                 ['C', 'D'],
    //                                ['E', 'F']
    //                            ];
            var item = new Array();
            for (var i = 0; i < 10; i++) {
                item[i] = i + 1;
            }
            for (var i = 0; i < item.length; i++) {
                osel.options.add(new Option(item[i], i))
            }
    //-->
        </script>
       

        <script language="javascript" type="text/javascript">
            function test() {
                var osel = document.getElementById("osel");
                alert(osel.selectedIndex);
                alert(osel.options[osel.selectedIndex].text);
                alert(osel.options[osel.selectedIndex].value);
            }
        </script>

        <input id="Button1" type="button" value="button" onclick="test();" />
    </body>
    </html>

  • 相关阅读:
    在centos7上使用packstack安装openstack
    解决 React-Native: Android project not found. Maybe run react-native android first?
    javascript_11-函数面试题
    javascript_10-函数
    前端面试记录NO.1
    javascript_09-数组
    javascript_08-while 和 do while
    javascript_07-break 和 continue
    javascript_05-操作符
    javascript_06-控制流程
  • 原文地址:https://www.cnblogs.com/shuyu/p/1704332.html
Copyright © 2020-2023  润新知