学渣
己所不欲,勿施于人
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <select id="MySelect">
        <option value="1">选项A</option>
        <option value="2">选项B</option>
    </select>
</body>
</html>
HTML代码
<script type="text/javascript">
    /*
    普通JS脚本获取
    */
    var mySelect = document.getElementById("MySelect"); //找到下拉列表控件
    var selectIndex = mySelect.selectedIndex; //获取选中项的索引
    var text = mySelect.options[selectIndex].text; //选中项的文本
    var value = obj.options[index].value; // 选中项的值

    /*
    通过jQuery获取
    */
    $("#MySelect option:selected").text();//选中的文本
    $("#MySelect option:selected").val();//选中项的值

</script>
JS代码

 

posted on 2015-03-06 17:53  西米阿耶  阅读(386)  评论(0编辑  收藏  举报