在前端获取select的value比较容易,用getElementById('id')或jquery的$(#'id').val()就可,获取select的文本内容则需要用select对象的options[obj.selectedIndex].text,看js代码
<select id="test" name="cc" onchange="change()">
<option value="1">10</option>
<option value="2">20</option>
<option value="3">30</option>
</select>
<script>
function change(){
//alert('seel');
var sel = document.getElementById("test");
alert(sel.value);
var text = sel.options[sel.selectedIndex].text;
alert(text);
// jquery catch select text
var checkText=$("#test").find("option:selected").text();
alert('jquery catch select text'+checkText);
}
</script>
JQuery获取select的文本内容的表达式 $("#select_id").find("option:selected").text()
分享到:
相关推荐
jQuery获取Select选择的Text和_Value
jQuery获取Select标签的手册 单选组radio: $("input[type=radio][checked]").val(); 下拉框select的value值: $('select').val(); 下拉框select选中的text 值:$("select").find("option:selected").text();
1、jquery获取当前选中select的text值 var checkText=$(“#slc1”).find(“option:selected”).text(); 2、jquery获取当前选中select的value值 var checkValue=$(“#slc1”).val(); 3、jquery获取当前选中select的...
下面小编就为大家分享一篇用jquery获取select标签中选中的option值及文本的示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
jQuery获取Select选择的Text和Value: 代码如下: $(“#select_id”).change(function(){//code…}); //为Select添加事件,当选择其中一项时触发 var checkText=$(“#select_id”).find(“option:selected”).text(); ...
下面小编就为大家带来一篇jquery获取select,option所有的value和text的实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
jQuery获取Select选择的Text和Value: 代码如下: var checkText=jQuery(“#select_id”).find(“option:selected”).text(); //获取Select选择的Text var checkValue=jQuery(“#select_id”).val(); //获取Select选择...
jQuery获取Select选择的Text和Value: 选择一项试试看 语法解释: 代码如下: . $(“#select_id”).change(function(){//code…}); //为Select添加事件,当选择其中一项时触发 . var checkText=$(“#select_id”)....
$("#sel_div .select_class option[id='-\u9009\u62e9\u7701-']").text(data.province).attr("selected",true); $("#sel_div .select_class option[id='-\u9009\u62e9\u5e02-']").text( data.city).attr("selected...
语法解释: 代码如下: 1.... //获取Select选择的Text 3. var checkValue=$(“#select_id”).val(); //获取Select选择的Value 4. var checkIndex=$(“#select_id “).get(0).selectedIndex; //获取Select选择的索
jquery取radio单选按钮的值$(“input[name=’items’]:checked”).... 获取select被选中项的文本 var item = $(“select[name=items] option[selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_
本文实例讲述了jquery获取select选中值的方法。分享给大家供大家参考,具体如下: 误区: 以前一直以为jquery获取select中option被选中的文本值,是这样写的: 复制代码 代码如下:$(“#s”).text(); //获取所有...
jquery获取select选择的文本与值 获取select 选中的 text : $(“#ddlregtype”).find(“option:selected”).text(); 获取select选中的 value: $(“#ddlregtype “).val(); 获取select选中的索引: $(“#ddlregtype ...
省市区三级联动[JSON+Jquery] 用alert()方法显示选中的值 var prov=$("#selProvince option:selected"); var city=$("#selCity option:selected"); var dist=$("#selDistrict option:selected"); alert...
Jquery操作select标签:包含选中、更改选中;获取选中option的text值、value值和ndex索引值;标签的清空、删除和增加等。
获取select被选中项的文本 var item = $(“select[name=items] option[selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_id’)[0].selectedIndex = 1; radio单选组的第二个元素为当前选中值...
获取select 选中的 text : $("#ddlregtype").find("option:selected").text(); 获取select选中的 value: $("#ddlregtype ").val(); 获取select选中的索引: $("#ddlregtype ").get(0).selectedindex; 设置...
JQuery获取和设置Select选项方法汇总如下: ... //获取Select选择的Textvar checkValue=$(“#select_id”).val(); //获取Select选择的Valuevar checkIndex=$(“#select_id “).get(0).selectedIndex;
获取select被选中项的文本 var item = $(“select[@name=items] option[@selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_id’)[0].selectedIndex = 1; radio单选组的第二个元素为当前选中...