jQuery获取Select选中的值

通过JQuery获取select控件的值:

<select id="citys">

    <option value="">请选择</option>

    <option value="shengzheng">深圳</option>

    <option value="guangzhou">广州</option>

</select>

 

<script type="text/javascript">

    alert($("#citys :selected").html());

    alert($("#citys :selected").val());

</script>

 

方法说明:$("#citys :selected") 获取ID citys select对象, :selected是筛选被选中的option.

.html() 是获得选项的文字, .val() 是获得选项的值!

原文地址:https://www.cnblogs.com/cookray/p/2733149.html