`
geeksun
  • 浏览: 952967 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

获取select的text内容(jquery)

 
阅读更多

       在前端获取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选择的Text和_Value

    jQuery获取Select标签的手册

    jQuery获取Select标签的手册 单选组radio: $("input[type=radio][checked]").val(); 下拉框select的value值: $('select').val(); 下拉框select选中的text 值:$("select").find("option:selected").text();

    jQuery操作select下拉框的text值和value值的方法

    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标签中选中的option值及文本的示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    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,option所有的value和text的实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    JQuery给元素添加/删除节点比如select

    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(获取/设置/添加/删除)

    jQuery获取Select选择的Text和Value: 选择一项试试看 语法解释: 代码如下: . $(“#select_id”).change(function(){//code…}); //为Select添加事件,当选择其中一项时触发 . var checkText=$(“#select_id”)....

    JQuery 获取多个select标签option的text内容(实例)

    $("#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...

    jQuery获取Select选择的Text和Value(详细汇总)

    语法解释: 代码如下: 1.... //获取Select选择的Text 3. var checkValue=$(“#select_id”).val(); //获取Select选择的Value 4. var checkIndex=$(“#select_id “).get(0).selectedIndex; //获取Select选择的索

    jquery获取input表单值的代码

    jquery取radio单选按钮的值$(“input[name=’items’]:checked”).... 获取select被选中项的文本 var item = $(“select[name=items] option[selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_

    jquery获取select选中值的方法分析

    本文实例讲述了jquery获取select选中值的方法。分享给大家供大家参考,具体如下: 误区: 以前一直以为jquery获取select中option被选中的文本值,是这样写的: 复制代码 代码如下:$(“#s”).text(); //获取所有...

    jquery中获取select选中值的代码

    jquery获取select选择的文本与值 获取select 选中的 text : $(“#ddlregtype”).find(“option:selected”).text(); 获取select选中的 value: $(“#ddlregtype “).val(); 获取select选中的索引: $(“#ddlregtype ...

    页面如何获取select框选中值(实例)

    省市区三级联动[JSON+Jquery] 用alert()方法显示选中的值 var prov=$("#selProvince option:selected"); var city=$("#selCity option:selected"); var dist=$("#selDistrict option:selected"); alert...

    Jquery操作select标签例子

    Jquery操作select标签:包含选中、更改选中;获取选中option的text值、value值和ndex索引值;标签的清空、删除和增加等。

    jquery获取元素值的方法(常见的表单元素)

    获取select被选中项的文本 var item = $(“select[name=items] option[selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_id’)[0].selectedIndex = 1; radio单选组的第二个元素为当前选中值...

    jQuery取得设置清空select选择的文本与值

    获取select 选中的 text : $("#ddlregtype").find("option:selected").text(); 获取select选中的 value: $("#ddlregtype ").val(); 获取select选中的索引: $("#ddlregtype ").get(0).selectedindex; 设置...

    jquery下拉select控件操作方法分享(jquery操作select)

    JQuery获取和设置Select选项方法汇总如下: ... //获取Select选择的Textvar checkValue=$(“#select_id”).val(); //获取Select选择的Valuevar checkIndex=$(“#select_id “).get(0).selectedIndex; 

    Jquery 获取表单text,areatext,radio,checkbox,select值的代码

    获取select被选中项的文本 var item = $(“select[@name=items] option[@selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_id’)[0].selectedIndex = 1; radio单选组的第二个元素为当前选中...

Global site tag (gtag.js) - Google Analytics