首页 > Web开发 > 详细

js获取select标签选中的值

时间:2016-06-03 14:27:39      阅读:263      评论:0      收藏:0      [点我收藏+]

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();//选中的文本
…….val();
…….get(0).selectedIndex;

 

 

http://blog.csdn.net/foart/article/details/6614829   //原文

js获取select标签选中的值

原文:http://www.cnblogs.com/shaohaixiong/p/5556004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!