js获取select标签选中的值
2015-11-17 21:21
609 查看
用js获取选中select的值
var obj = document.getElementByIdx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // 选中索引
var text = obj.options[index].text; // 选中文本
var value = obj.options[index].value; // 选中值
用jQuery获取选中select值
第一种方式
$('#testSelect option:selected').text();//选中的文本
$('#testSelect option:selected') .val();//选中的值
$("#testSelect ").get(0).selectedIndex;//索引
第二种方式
$("#tesetSelect").find("option:selected").text();//选中的文本
$("#tesetSelect").find("option:selected").val();
$("#tesetSelect").find("option:selected").get(0).selectedIndex;
更多干货等你来拿 http://www.itit123.cn/
var obj = document.getElementByIdx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // 选中索引
var text = obj.options[index].text; // 选中文本
var value = obj.options[index].value; // 选中值
用jQuery获取选中select值
第一种方式
$('#testSelect option:selected').text();//选中的文本
$('#testSelect option:selected') .val();//选中的值
$("#testSelect ").get(0).selectedIndex;//索引
第二种方式
$("#tesetSelect").find("option:selected").text();//选中的文本
$("#tesetSelect").find("option:selected").val();
$("#tesetSelect").find("option:selected").get(0).selectedIndex;
更多干货等你来拿 http://www.itit123.cn/
相关文章推荐
- JS-Date对象
- Js event事件在IE、FF兼容性问题
- jsp+ajax自动刷新局部页面
- js对日期格式化
- javascript使用的两项原则和Hijax
- JavaScript中清空数组的三种方式
- JS-Array对象
- JSP运行原理、指令元素及内建对象
- JavaScript DOM编程艺术—动态创建标记
- JS获取MVC Attrbuate验证是否通用
- js表单操作
- JavaScript DOM编程艺术-JavaScript图片库
- js字符串的方法
- codemirror覆盖默认按键事件
- JS绑定事件
- JavaScript中confirm,alert,prompt的用法及返回值
- js 数组循环遍历
- js的三种使用方式
- Why Javascript only works after opening developer tools in IE once?
- Json.net 时间格式处理