js 获取select option中的值或者value值

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<select id="sel" οnchange="cge()">
   <option value="1">4</option>
   <option value="2">5</option>
   <option value="3">6</option>
</select>
</body>
<script>
    function cge(){
        var sel=document.getElementById('sel');
                var sid=sel.selectedIndex;
        alert('value值:'+sel[sid].value+',option值:'+sel[sid].innerHTML);
    }
</script>
</html>

 

猜你喜欢

转载自www.cnblogs.com/qcjdp/p/12606432.html