如何用jQuery获得radio的值
如何获得radio的值,在网上查了一下,下面总结几种解决方法,。
1.获取选中值:
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();
2.设置第一个Radio为选中值:
$('input:radio:first').attr('checked', 'checked');
$('input:radio:first').attr('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').attr('checked', 'checked');
$('input:radio:last').attr('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).attr('checked', 'true');索引值=,,....
$('input:radio').slice(,).attr('checked', 'true');
5.根据Value值设置Radio为选中值
$(":radio[name='rbsex'][value='" + sex + "']").prop("checked", "checked");
如何用jQuery获得radio的值的更多相关文章
- 使用jquery获取radio的值
使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: ...
- jquery获取radio选中值及遍历
使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项:1.& ...
- 如何用jQuery获得select的值
如何用jQuery获得select的值,在网上找了看了一下,下面将总结一下: 1.获取第一个option的值 $('#test option:first').val(); 2.最后一个o ...
- Jquery常用radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关设置
获取一组radio被选中项的值:var item = $('input[name=items][checked]').val(); 获取select被选中项的文本:var item = $(" ...
- Jquery 操作 radio选中值
1.获取radio选中值 1.1 $('input:radio:checked').val(); 1.2 $("input[type='radio']:checked").va ...
- Jquery 获取 radio选中值,select选中值
随着Jquery的作用越来越大,使用的朋友也越来越多.在Web中,由于CheckBox.Radiobutton .DropDownList等控件使用的频率比较高,就关系到这些控件在Jquery中的操作 ...
- 纠正jQuery获取radio选中值的写法
先看一段代码 <input type="radio" name="aaa" value="1" checked="true& ...
- jquery获取radio的值
Html代码是 <label><input type="radio" name="proofing" value="1"& ...
- jQuery取得radio的值 取select得值
获取一组单选按钮对象: var obj_payPlatform = $('#wrap input[name="payMethod"]'); 获取被选中按钮的值 : var val_ ...
随机推荐
- Apple - Hdu5160
Problem Description We are going to distribute apples to n children. Every child has his/her desired ...
- [洛谷P5174]圆点
题目大意:给你$R(R\leqslant10^{14})$,求:$$\sum\limits_{x\in\mathbb{Z}}\sum\limits_{y\in\mathbb{Z}}[x^2+y^2\l ...
- axios请求,拦截器的使用
1. axios 创建请求 import axios from 'axios' import {Message} from 'element-ui' import router from " ...
- Linux(ubuntu 12.04桌面版) 搭建Android开发环境
因为一些工作上的原因,需要切换到Linux环境下做点开发,我选择的Linux发行版本为ubuntu(我不建议使用fedora,我最开始就是使用的fedora,但发现并不是特别好使,有些插件没办法安装, ...
- POJ1816:Wild Words——题解
http://poj.org/problem?id=1816 比较麻烦的trie. 首先你需要选择针对n还是m建立trie,这里我选择了针对n. 那么就需要面临卡空间的问题. 这里提供了一种链式前向星 ...
- LUOGU 1440
#include<cstdio> #include<algorithm> #include<cstring> #define N 1000005 using nam ...
- Linux实验一
一.Linux 简介 1.Linux 就是一个操作系统,就像你多少已经了解的 Windows(xp,7,8)和 Max OS , 我们的 Linux 也就是系统调用和内核那两层,当然直观的来看,我们使 ...
- ContestHunter暑假欢乐赛 SRM 02
惨不忍睹 3个小时都干了些什么... 日常按顺序从A题开始(难度居然又不是递增的 第一眼A题就觉得很简单...写到一半才发现woc那是个环.感觉一下子复杂了,按照链的方法扩展的话要特判很多东西... ...
- BZOJ1491 洛谷2047 NOI2007 社交网络
Description: 在社交网络(social network)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题.在一个社交圈子里有n个人,人与人之间有不同程度的关系.我 们 ...
- eclipse中支持python
1. 启动eclipse,help-> Install New Software; 2. 点击add 3. 设置Repository name: pydev Location: http://p ...