jQuery操作<input type="radio">
来源:互联网 发布:淘宝做话费充值 编辑:程序博客网 时间:2024/06/15 00:37
转自:http://www.cnblogs.com/luxh/archive/2012/06/07/2538281.html
<input type="radio">如下:
<input type="radio" name="city" value="BeiJing">北京<input type="radio" name="city" value="TianJin">天津<input type="radio" name="city" value="NanJing">南京<input type="radio" name="city" value="YangZhou">扬州<input type="radio" name="city" value="SuZhou">苏州
1、获取选中的radio的值:
$("input[name='city']:checked").val();
使用元素选择器,再使用属性过滤器name='city',最后使用:checked选取被选中的元素。
2、给指定值的radio设置选中状态:
$("input[name='city'][value='YangZhou']").attr("checked",true);
给name="city"而且value="YangZhou"的radio设置选中状态。
3、取消name="city"的radio的选中状态:
$('input[name="city"]:checked').attr("checked",false);
4、获取name="city"的radio的个数:
$("input[name='city']").length;
5、获取name="city"而且索引是偶数的radio:
$("input[name='city']:even");
索引是从0开始的。
6、获取name="city"而且索引是奇数的radio:
$("input[name='city']:odd");
索引是从0开始的。
7、迭代radio:
$("input[name='city']").each(function(i,obj){ //i,迭代的下标,从0开始 //obj,当前的对象(HTMLInputElement),可以使用obj.value格式获取属性值 //$(this);当前jQuery对象,可以使用$(this).val()获取属性值});
迭代name="city"的radio。
8、禁用radio:
$("input[name='city']").attr("disabled",true);
禁用name="city"的radio。
9、启用radio:
$("input[name='city']").attr("disabled",false);
启用name="city"的radio。
0 0
- jQuery操作<input type="radio">
- jQuery操作<input type="radio">
- jQuery操作<input type="radio">
- jQuery操作radiojQuery操作<input type="radio">
- jQuery操作input type=radio的实现代码
- jquery对象控制type=radio的input问题解决方法:
- jQuery操作<input type="checkbox">
- jQuery操作<input type="checkbox">
- struts2 <input type="radio" 默认选中
- input type="radio" 的用法
- 自定义input[type=radio]单选框样式
- angularjs input type=radio isChecked
- 自定义input[type="radio"]的样式
- 多个单选框 input type="radio"选中效果
- 判断input[type="radio"]是否选中
- jQuery设置input type="radio" 哪个值为被选中的
- jquery根据特定的值设置 input type=radio 单选框为选中状态
- jQuery操作 input type=checkbox的实现代码
- JVM调优总结(一) ——概念
- CCITT标准CRC16(1021) Java代码
- Linux下使用交叉编译工具ltib开发powerpc(mpc83xx)
- msysGit 安装配置
- Spring技术入门(二)
- jQuery操作<input type="radio">
- ElasticSearch 原理笔记
- 网站特效
- Linux中rc的含义
- linux tomcat
- 二叉树的遍历
- UltraEdit不自动生成保存备份文件(.bak)
- 世界杯:一句顺其自然,里面包含了我多少绝望和不甘心
- 立体类族共有的抽象类