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();$(" ...
- 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次数据库查 ...
随机推荐
- Master-Worker模式
并行程序设计模式--Master-Worker模式 简介 Master-Worker模式是常用的并行设计模式.它的核心思想是,系统有两个进程协议工作:Master进程和Worker进程.Master进 ...
- 如何在android的mk文件添加依赖已经编译好的库
用$(MY_LIB)是代表你的库的所在目录,目录结构是这样 MY_LIB |---include |-----xxx.h |-----xxx.h |---lib |----MYLIB.a LOCAL_ ...
- zpf 视图
2014年8月19日 18:12:16 smarty使用了2年, 使用PHP本身做模版引擎也有4个多月了, 最终还是在我的这个框架中抛弃了smarty,转用原生的PHP代码做模版引擎,并简单写了一个视 ...
- android 初探
2014年7月27日 15:02:57 附: android 官方培训课程中文版 //官方简单的入门教程, 每个大类中只介绍了几个知识点, 可以快速搭建一个hello world android 开发 ...
- 【JAVA、C++】LeetCode 009 Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 解题思路一: 双指针法,逐位判断 Java代码如下 ...
- 完善DriveInfoEx源代码 获取计算机硬盘序列号
概述: 获取计算机硬盘序列号用途很多,在网上找到了一个C++的源代码DriveInfoEx(点这里查看).非常好的一个DLL,.NET项目可以直接引用,而且源代码里有示例. 但这个DLL在Win7非管 ...
- 修改PHP网站默认首页
一般默认的首页文件是index.php index.php3 index.html index.htm之类的,要想修改为myNewIndex.php, 进入服务器Apache目录,找到httpd.co ...
- MapReduce:详解Shuffle过程(转)
/** * author : 冶秀刚 * mail : dennyy99@gmail.com */ Shuffle过程是MapReduce的核心,也被称为奇迹发生的地方.要想理解MapRedu ...
- an error occurred during the file system check错误的解决
[root@GIT ~]# fsck -A /dev/mapper/VolGroup-lv_root 下面的选择,一路Y就行了,最后reboot,问题解决!
- jdk
mkdir java mv jdk1.7.0_71/ java/ [root@centos02 src]# java -version java version "1.7.0_71" ...