如何获得select被选中option的value和text
来源:互联网 发布:淘宝玩具古剑 编辑:程序博客网 时间:2024/05/21 14:48
一:JavaScript原生的方法
拿到select对象: var myselect=document.getElementById(“test”);拿到选中项的索引:var index=myselect.selectedIndex ; // selectedIndex代表的是你所选中项的index拿到选中项options的value: myselect.options[index].value;拿到选中项options的text: myselect.options[index].text;
二:jQuery方法(前提是已经加载了jquery库)
var options=$(“#test option:selected”); //获取选中的项alert(options.val()); //拿到选中项的值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
- 使用CMS快速搭建商业网站
- 线段树模板
- 搭建ELK(ElasticSearch+Logstash+Kibana)日志分析系统(十) elasticsearch集群部署
- VsCode插件整理
- mongodb添加修改用户,设置权限
- 如何获得select被选中option的value和text
- P2460清理花瓶
- 博客搬家
- Android使用讯飞SDK开发语音识别及合成小Demo
- Android应用更改系统语言
- prime flyd 基础算法
- Git 推送项目新内容
- 今天在数据库中做插入时,提醒“当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'TB_Admin_Role' 中的标识列插入显式值。”的问题。
- 怎么分辨博文的好坏