jquery 获取和设置Select选项常用方法总结
1.获取select 选中的 text:
$("#cusChildTypeId").find("option:selected").text();
$("#cusChildTypeId option:selected").text()
2.获取select选中的 value:
$("#ddlRegType ").val();
3.获取select选中的索引:
       $("#ddlRegType ").get(0).selectedIndex;
4.得到select项的个数    
$("#cusChildTypeId").get(0).options.length
5.设置select 选中的索引:
      $("#cusChildTypeId").get(0).selectedIndex=index;//index为索引值
6.设置select 选中的value:
     $("#cusChildTypeId").attr("value","Normal");
     $("#cusChildTypeId").val("Normal");
     $("#cusChildTypeId").get(0).value = "Normal";
7.设置select 选中的text:
1>.var count=$("#cusChildTypeId").get(0).options.length;
      for(var i=0;i<count;i++)  
          {            
if($("#cusChildTypeId").get(0).options.text == text)  
          {  
              $("#cusChildTypeId").get(0).options.selected = true;
              break;  
          }  
         }
2>.$("#cusChildTypeId").val(text);
     $("#cusChildTypeId").change();
8.向select中添加一项,显示内容为text,值为value    
$("#cusChildTypeId").get(0).options.add(new Option(text,value));
9.删除select中值为value的项 
         var count = $("#cusChildTypeId").size();            
         for(var i=0;i<count;i++)    
         {    
             if($("#cusChildTypeId").get(0).options[i].value == value)    
             {    
                 $("#cusChildTypeId").get(0).remove(i);    
                 break;    
             }
         }
10.清空 Select:
1>. $("#cusChildTypeId").empty();
2>. $("#cusChildTypeId").get(0).options.length = 0;
jquery 获取和设置Select选项常用方法总结的更多相关文章
- JQuery获取和设置Select选项常用方法总结 (转)
		
1.获取select 选中的 text: $("#cusChildTypeId").find("option:selected").text(); $(&quo ...
 - JQuery获取和设置Select选项常用方法总结
		
1.获取select 选中的 text: $("#cusChildTypeId").find("option:selected").text(); $(&quo ...
 - JQuery获取和设置Select选项的常用方法总结
		
1.获取select 选中的 text: $("#cusChildTypeId").find("option:selected").text(); $(&q ...
 - jquery 获取和设置 select下拉框的值(转手册)
		
##实例应用中遇到的问题 //在某事件响应的应用中设置select选中项,前两种情况的设置不生效,使用了最后一种用法才生效的 //$("#select_time").find(&q ...
 - jquery 获取和设置 select下拉框的值
		
获取Select : 获取select 选中的 text : $("#ddlRegType").find("option:selected").text(); ...
 - JQuery获取和设置select下拉框的值
		
获取Select : 获取select 选中的 text : $("#sid").find("option:selected").text(); 获取selec ...
 - JQuery获取与设置select
		
获取select : 1.获取select 选中的 text : $("#ddlregtype").find("option:selected").tex ...
 - jquery获取和设置元素高度宽度
		
jquery获取和设置元素高度宽度 1.height()/ width() 取得第一个匹配元素当前计算的高度/宽度值(px) height(val)/ width(val) 为每个匹配的元素设置CSS ...
 - JQuery获取与设置HTML元素的值value
		
JQuery获取与设置HTML元素的值value 作者:简明现代魔法图书馆 发布时间:2011-07-07 10:16:13 20481 次阅读 服务器君一共花费了13.221 ms进行了6次数据库查 ...
 
随机推荐
- JUC线程池之 线程池架构
			
线程池的架构图如下: Executor 它是"执行者"接口,它是来执行任务的.准确的说,Executor提供了execute()接口来执行已提交的 Runnable 任务的对象.E ...
 - linux raid10管理维护
			
http://www.linuxidc.com/Linux/2015-10/124391.htm 制作raid10 http://www.linuxidc.com/Linux/2015-09/1 ...
 - MySQL集群Percona XtraDB Cluster安装搭建步骤详解
			
http://www.linuxidc.com/Linux/2017-05/143501.htm http://blog.csdn.net/thundermeng/article/details/52 ...
 - asp.net 退出登陆(解决退出后点击浏览器后退问题仍然可回到页面问题)
			
代码如下: Session.Abandon(); Response.Redirect("Login.aspx"); 但是这样点点击浏览器的后退仍然可以回到刚才的页面,这可不行,在网 ...
 - JavaScript模块化-RequireJs实现AMD规范的简单例子
			
AMD规范简介 AMD(异步模块定义),是实现JavaScript模块化规范之一,它采用异步方式加载模块,模块的加载不影响后面语句的运行.require.js和curl.js都是实现AMD规范的优秀加 ...
 - windows下使用vscode编写运行以及调试Python
			
更新于2018年10月: 首先去python官网下载python3 地址:https://www.python.org/downloads/windows/ 下载好后直接安装 记得勾选添加环境变量 ...
 - Java\学习——字符串
			
import java.util.Scanner; public class cys1 { /** * @param args */ public static void main(String[] ...
 - 杂项-性能测试工具:LoadRunner
			
ylbtech-杂项-性能测试工具:LoadRunner LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找问题,LoadR ...
 - 使用postman模拟appium的http请求
			
Appium是Server,接收http请求,使用Postman模拟请求 1.anyproxy 1.1.安装和运行 #安装 npm i -g anyproxy # 运行anyproxy,端口默认800 ...
 - 正则的使用及replace细讲
			
1.var reg=/./ 与 var reg=/\./的区别? .代表任意一个字符 \.而后者代表这个字符串中得有一个. 2.?的使用 如果单独的一个字符后面带? /\d?/ 代表1个或0个这个字符 ...