如何获得select被选中option的value和text
来源:互联网 发布:竹庆本乐仁波切 知乎 编辑:程序博客网 时间:2024/06/04 23:23
一:javascript原生的方法
1:拿到select对象: var myselect=document.getElementById(“test”);
2:拿到选中项的索引:var index=myselect.selectedIndex ; // selectedIndex代表的是你所选中项的index
3:拿到选中项options的value: myselect.options[index].value;
4:拿到选中项options的text: myselect.options[index].text;
二:jquery方法(前提是已经加载了jquery库)
1:var options=$(“#test option:selected”); //获取选中的项
2:alert(options.val()); //拿到选中项的值
3:alert(options.text()); //拿到选中项的文本
0 0
- 如何获得select被选中option的value和text
- 如何获得select被选中option的value和text
- 如何获得select被选中option的value和text和......
- 如何获得select被选中option的value和text和其他属性值
- jquery获得select选中项的text和value
- web 获取select中被选中option的value和text
- 如何获得select被选中option的值
- 根据select中option的text或value来选中
- js实例,获取选中select标签的value和option text值
- 用脚本语言如何得到在select中被选中的选项的value和text
- jQuery操作Select获取被选中的Text和Value
- 如何获得select选中的是那个option
- jQuery获取Select option 选择的Text和Value
- jQuery获取Select option 选择的Text和 Value(转)
- jQuery获取Select option 选择的Text和Value
- jQuery获取Select option 选择的Text和 Value(转)
- jQuery获取Select option 选择的Text和Value
- jQuery获取Select option 选择的Text和Value
- MySQL 加锁处理分析
- python set集合的基本操作
- 36. Valid Sudoku
- XILINX DDR3 wr_count rd_count不能连续计数问题
- TCP/IP详解 卷一 ------IGMP
- 如何获得select被选中option的value和text
- <高性能javascript>阅读笔记一 ---关于脚本放的位置以及加载方式
- VS 进行调试时,打不开*.exe 可能的原因
- 打开设置网络界面
- 单例模式(懒汉模式、饿汉模式)
- react-native工程 打包
- 《Flex+PHP RIA应用开发实战详解-梁文新版》学习日记1
- iOS 最新提示Unable to add App ID because the '10' App ID limit in '7' days has been exceeded.
- 用Smack开发Android即时通讯