jQuery获取循环中的选中单选按钮radio的值
2015-12-27 15:32
771 查看
1.<input type="radio" name="testradio" value="jquery获取radio的值" />jquery获取radio的值 2.<input type="radio" name="testradio" value="jquery获取checkbox的值" />jquery获取checkbox的值 3.<input type="radio" name="testradio" value="jquery获取select的值" />jquery获取select的值 要想获取某个radio的值有以下的几种方法,直接给出代码:
1.$('input[name="testradio"]:checked').val();2、 1.$('input:radio:checked').val();3、 1.$('input[@name="testradio"][checked]');4、 1.$('input[name="testradio"]').filter(':checked');差不多挺全的了,如果我们要遍历name为testradio的所有radio呢,代码如下 1.$('input[name="testradio"]').each(function(){2.alert(this.value);3.});如果要取具体某个radio的值,比如第二个radio的值,这样写 1.$('input[name="testradio"]:eq(1)').val() 以上的是网上的,一下:
<table class="table table-bordered"> <thead> <tr> <th style="vertical-align:middle" class="text-center" rowspan="2">单选按钮操作</th> </tr> </thead> <tbody> #foreach($item in [1,2,3,4,5]) <tr> <td> <input type="radio" name="audit$!{item}" value="1" checked>通过 <input type="radio" name="audit$!{item}" value="0">驳回 </td> </tr> </table> 以上动态的,每行都有一对单选radio,此时获取选中的每行的值,则代码如下:
$('input:radio:checked').each(function(){ //var checkValue = $(this).val(); console.log($(this).val()); // 选中框中的值 });
相关文章推荐
- 《jQuery基础教程》第四版第七章课后练习——使用插件
- jquery自动刷新页面的几种方法
- 全屏滚动-jQuery插件实现
- jquery中的选择器01
- jQuery 和 json 简单例子(注意callback函数的处理!!) (servlet返回json,jquery更新,java json)
- jQuery实现下拉菜单
- jQuery实现下拉菜单
- 【东臣PHP】JQuery+Ajax
- 【嘉兴东臣php】jquery
- 【嘉兴东臣PHP】 闭包+JQuery
- jQuery on() 绑定无效的解决办法
- 【嘉兴东臣php】节点 ajax请求 jquery基本语法
- 【嘉兴东臣php】闭包+Jquery+Ajax周总结
- jQuery学习--jQuery选择器
- 2015/12/26--jquery(02)
- jQuery学习--jQuery页面加载完成事件
- jQuery的form表单验证
- Jquery Ajax 异步设置Table中某列的值
- jQuery权限分配-列表框的应用
- 汇总常用的jQuery操作Table tr td方法