jQuery操作<input type="radio">
来源:互联网 发布:淘宝游戏点卡货源 编辑:程序博客网 时间:2024/06/05 11:59
<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。
转自:http://www.cnblogs.com/luxh/archive/2012/06/07/2538281.html
- 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的实现代码
- 玩家就是宇宙,而你就是那个玩家——谈Minecraft
- 编译VTK的MFC库
- C#全局键盘钩子
- Android NDK: ERROR: You NDK_MODULE_PATH variable contains spaces
- 二叉树的先序遍历 Binary Tree Preorder Traversal
- jQuery操作<input type="radio">
- hdu 2845
- 用单链表解约瑟夫环问题!
- EntityFramework走马观花之CRUD(下)
- move table and purge table
- java.io.IOException: 您的主机中的软件放弃了一个已建立的连接
- "new types may not be defined in a return type" error
- java获取classpath文件路径空格转变成了转义字符%20的问题解决 !
- Qt类简介之QWidget类(1)