jQuery操作<input type="radio">
2014-04-30 02:32
471 查看
<input type="radio">如下:
1、获取选中的radio的值:
使用元素选择器,再使用属性过滤器name='city',最后使用:checked选取被选中的元素。
2、给指定值的radio设置选中状态:
给name="city"而且value="YangZhou"的radio设置选中状态。
3、取消name="city"的radio的选中状态:
4、获取name="city"的radio的个数:
5、获取name="city"而且索引是偶数的radio:
索引是从0开始的。
6、获取name="city"而且索引是奇数的radio:
索引是从0开始的。
7、迭代radio:
迭代name="city"的radio。
8、禁用radio:
禁用name="city"的radio。
9、启用radio:
启用name="city"的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。
相关文章推荐
- jQuery操作<input type="radio">
- [转]jQuery操作<input type="radio">
- jQuery操作<input type="radio">
- jQuery操作<input type="radio">
- jQuery操作<input type="checkbox">
- <input type="radio" >与<input type="checkbox">值得获取
- 页面<input type="radio"...>取值
- JQuery------获取<input type="file">中的文件内容
- jQuery操作<input type="radio">
- JS获取jQuery获取当前<input type="text" />的value--通过测试了
- <input type="radio" />的选中和禁用
- Jquery 获得<input type="text" id="test">中的value
- jQuery操作radiojQuery操作<input type="radio">
- JQuery------获取<input type="file">中的文件内容
- jQuery动态添加<input type="file">
- 选择多个文件上传<input type="file" id="myfileinput" multiple>
- jsp <input type="file"> 清空value值的一种方式
- 让HTML中的文本框<input type="text">中的文字垂直居中
- <button ></button>与<input type="button" />的区别
- jQuery设置input type="radio" 哪个值为被选中的