zoukankan      html  css  js  c++  java
  • JavaScript为select添加option,select选项变化时的处理,获取slelect被选中的值

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>测试文件</title>
    <script>
    window.onload = function(){
        //创建select控件
        var _select = document.createElement("SELECT");
        
        //添加选项
        for(var i=1; i<=10; i++){
            var _option = new Option(i,i);
            _select.options.add(_option);
        }
        
        //选中值发生改变时的处理函数
        _select.onchange = function(){
            alert(_select.value); //取select控件被选中的值
        }
        
        document.body.appendChild(_select);
    }
    </script>
    </head>
    
    <body>
    </body>
    </html>
  • 相关阅读:
    find
    fdisk
    falcon-eye
    ethtools
    e2fsck
    dpkg
    declare
    df
    debconf-utils
    区块链从零开始做开发(0):hyperledger Fabric2.3安装
  • 原文地址:https://www.cnblogs.com/dige1993/p/4617399.html
Copyright © 2011-2022 走看看