DOM-获取下拉列表选中项的value

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>获取下拉列表选中项的value</title>
    </head>
    <body>
        <script type="text/javascript">
            window.onload=function(){
                var provinceListElt = document.getElementById("provinceList");
                provinceListElt.onchange=function(){
                    //获取选中项value
                    alert(provinceListElt.value );
                }
            }
        </script>
        <select id="provinceList" >
            <option value="">--请选择省份--</option>
            <option value="001">河北省</option>
            <option value="002">河南省</option>
            <option value="003">山东省</option>
            <option value="004">山西省</option>
        </select>
        
    </body>
</html>

 

posted @ 2022-06-13 14:02  280887072  阅读(15)  评论(0编辑  收藏  举报