jquery-radio
2016-04-21 15:25
543 查看
1.获取选中值,三种方法都可以:
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();
2.设置第一个Radio为选中值:
$('input:radio:first').prop('checked', 'checked');
或者
$('input:radio:first').prop('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').prop('checked', 'checked');
或者
$('input:radio:last').prop('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).prop('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).prop'checked', 'true');
5.根据Value值设置Radio为选中值
$("input:radio[value=http://www.2cto.com/kf/201110/'rd2']").prop('checked','true');
或者
$("input[value=http://www.2cto.com/kf/201110/'rd2']").prop('checked','true');
6. 取消radio
$("#tradeType1").prop("checked",false);
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();
2.设置第一个Radio为选中值:
$('input:radio:first').prop('checked', 'checked');
或者
$('input:radio:first').prop('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').prop('checked', 'checked');
或者
$('input:radio:last').prop('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).prop('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).prop'checked', 'true');
5.根据Value值设置Radio为选中值
$("input:radio[value=http://www.2cto.com/kf/201110/'rd2']").prop('checked','true');
或者
$("input[value=http://www.2cto.com/kf/201110/'rd2']").prop('checked','true');
6. 取消radio
$("#tradeType1").prop("checked",false);
相关文章推荐
- jquery datatables api (转)
- 浏览器兼容和jquery载入
- 10个常用Jquery代码片段
- Jquery实现图片的预加载与延时加载
- 使用jquery插件实现图片延迟加载技术(懒加载)
- JS/JQuery控制图片宽度
- jQuery使用伪递归重复执行动画
- jquery 回车事件
- JQuery实时监控文本框字符变化
- jQuery实现模拟滚动条效果;
- Jquery 删除最后一个元素
- jQuery实现拖动布局并将排序结果保存到数据库
- jQuery判断email地址 邮箱地址 email regex
- JQuery validate date 日期校验问题
- jQuery - Modal Window 15个模态窗口插件
- ajax+jquery实现父页面弹出子页面,选择提交后给父页面传值
- Java table列表 jQuery 绑定单元格change事件 取变更单元格的值
- jQuery对表单、表格的操作及更多应用
- 什么?你还不会写JQuery 插件
- jquery 图片轮播