«
js获取当前被选中的option值
生活点滴 教程资料 软件程序 Hyper-v虚拟化 魔方模块 Task 应用 织梦

时间:2020-9-1    作者:千古互动    分类: 生活点滴


<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<select id="sel" onchange="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(sel[sid].value+'-'+sel[sid].innerHTML);

}

</script>

</html>

jq的话就一句

$("#sel option:selected").text();

$("#sel option:selected").val();