博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js获取select标签选中的值
阅读量:4677 次
发布时间:2019-06-09

本文共 872 字,大约阅读时间需要 2 分钟。

var obj = document.getElementByIdx_x(”testSelect”); //定位idvar 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;   //获取选中的selecet的信息            var selecttext = $('#sourceSelect option:selected').text();            var selecttval = $("#sourceSelect option:selected").val();            var selecttid = $("#sourceSelect option:selected").id;            var seltext = $("#sourceSelect").find("option:selected").text();            var selval = $("#sourceSelect").find("option:selected").val();

 

转载于:https://www.cnblogs.com/zhanghongqiang/p/4097784.html

你可能感兴趣的文章
第二次作业
查看>>
ios 面试题
查看>>
express细节点注意
查看>>
MySQL教程(二)—— 关于在ACCESS中使用SQL语句
查看>>
实验4.1
查看>>
接口Interface
查看>>
bzoj 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚【贪心+堆||差分】
查看>>
bzoj 1710: [Usaco2007 Open]Cheappal 廉价回文【区间dp】
查看>>
电商:购物车模块解决思路
查看>>
Java中的Map List Set等集合类
查看>>
大道至简阅读笔记01
查看>>
多个模块使用python logging
查看>>
Linux高级变量
查看>>
php ffmpeg
查看>>
java中== 和 .equals()的区别
查看>>
网络流学习笔记
查看>>
让我们一起Go(二)
查看>>
Linq 中按照多个值进行分组(GroupBy)
查看>>
jquery validate
查看>>
模板函数与模板类
查看>>