Jquery 中的CheckBox、 RadioButton、 DropDownList的取值赋值
1.获取选中值,三种方法都可以:
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();
2.设置第一个Radio为选中值:
$('input:radio:first').attr('checked', 'checked');
或者
$('input:radio:first').attr('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').attr('checked', 'checked');
或者
$('input:radio:last').attr('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).attr('checked', 'true');
5.根据Value值设置Radio为选中值
$("input:radio[value='rd2']").attr('checked','true');
或者
$("input[value='rd2']").attr('checked','true');
6.删除Value值为rd2的Radio
$("input:radio[value='rd2']").remove();
7.删除第几个Radio
$("input:radio").eq(索引值).remove();索引值=0,1,2....
如删除第3个Radio:$("input:radio").eq(2).remove();
8.遍历Radio
$('input:radio').each(function(index,domEle){
//写入代码
});
最新文章
- LeetCode Moving Average from Data Stream
- linux基础-第十六单元 yum管理RPM包
- mybatis异常
- Vim tips
- [原 ->; 砖] C# IEnumerable<;T>;泛型取值
- android 登陆案例_sd卡
- (转)smarty实现多级分类的方法
- CSS知识点:清除浮动
- 在ERP中定义用户时报错:SqlDateTime 溢出。必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM 之间
- WINDOWS下运行ORACLE SQLPLUS时报错的一次记录
- PHP 点阵5*7字体
- [Swift]LeetCode363. 矩形区域不超过 K 的最大数值和 | Max Sum of Rectangle No Larger Than K
- jsonwebtoken收藏博客地址
- Swoole 心跳检测
- ngnix——FastCGI 相关参数调优
- 如何使用navicat远程连接服务器上的oracle数据库
- 容器内部设置JVM的Heap大小
- Spring JDBC调用存储函数
- 高斯混合模型Gaussian Mixture Model (GMM)
- Win32 API编程:使用CreateProcess创建新进程
热门文章
- 如何:为iOS 的方法写注释 让xcode 能够索引得到?
- 组织安全性SQL
- Getting OS version with NDK in C c++获得版本号
- java数字转换成文字方法
- 处理【Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operatio】
- Plupload设置自定义参数
- idea自动生成serialVersionUID , serialVersionUID的作用
- QT中文乱码与国际化支持
- webservice发布问题,部署iis后调用不成功
- 九度oj-1001-Java