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');索引值=0,1,2....

或者

$('input:radio').slice(1,2).attr('checked', 'true');

5.根据Value值设置Radio为选中值

$("input:radio[value=http://www.2cto.com/kf/201110/'rd2']").attr('checked','true');

或者

$("input[value=http://www.2cto.com/kf/201110/'rd2']").attr('checked','true');

6.删除Value值为rd2的Radio

$("input:radio[value=http://www.2cto.com/kf/201110/'rd2']").remove();

7.删除第几个Radio

$("input:radio").eq(索引值).remove();索引值=0,1,2....

如删除第3个Radio:$("input:radio").eq(2).remove();

8.遍历Radio

$('input:radio').each(function(index,domEle){

//写入代码

});

1.   获取选中项:

获取选中项的Value值:

$('select#sel option:selected').val();

或者

$('select#sel').find('option:selected').val();

获取选中项的Text值:

$('select#seloption:selected').text();

或者

$('select#sel').find('option:selected').text();

2.   获取当前选中项的索引值:

$('select#sel').get(0).selectedIndex;

3.   获取当前option的最大索引值:

$('select#sel option:last').attr("index")

4.   获取DropdownList的长度:

$('select#sel')[0].options.length;

或者

$('select#sel').get(0).options.length;

5.  设置第一个option为选中值:

$('select#sel option:first').attr('selected','true')

或者

$('select#sel')[0].selectedIndex = 0;

6.   设置最后一个option为选中值:

$('select#sel option:last').attr('selected','true')

radio应用的更多相关文章

  1. 前端开发:css技巧,如何设置select、radio 、 checkbox 、file这些不可直接设置的样式 。

    前言: 都说程序员有三宝:人傻,钱多,死得早.博主身边的程序“猿”一大半应了这三宝,这从侧面说明了一个问题,只有理性是过不好日子的.朋友们应该把工作与生活分开,让生活变得感性,让工作变得理性,两者相提 ...

  2. Get radio selected value

    先看下面 foreach得到的radio list: 现在想实现把选择的选项值Post至服务端:

  3. 绑定一个值给radio

    在ASP.NET MVC程序中,需要给一个radio list表绑定一个值. 下面是Insus.NET实现的方法: 使用foreach来循环radio每一个选项,如果值与选项的值相同,那这个选项为选中 ...

  4. jQuery 获取 radio 选中后的文字

    如果html为 <input type="radio" id="test" name="test" value="1&quo ...

  5. [转]jQuery操作radio、checkbox、select 集合.

    1.radio:单选框 html代码 <input type="radio" name="radio" id="radio1" val ...

  6. radio 切换内容

    <!DOCTYPE html><html><head> <meta charset=utf-8 /> <title>test</tit ...

  7. JQuery radio(单选按钮)操作方法汇总

    这篇文章主要介绍了JQuery radio(单选按钮)操作方法汇总,本文讲解了获取选中值.设置选中值.根据Value值设置选中.删除Radio.遍历等内容,需要的朋友可以参考下   随着Jquery的 ...

  8. GNU Radio Radar Toolbox

    GNU Radio Radar Toolbox Install guide Change to any folder in your home directory and enter followin ...

  9. 《jQuery判断radio、checkbox、select 是否选中和设置选中问题以及获取选中值》总结

    <form> <input type="radio" name="gender" id="man" value=" ...

  10. C#中用radio单选Repeater循环数据,js实现

    <asp:Repeater ID="rpt" runat="server"> <ItemTemplate> <tr data-id ...

随机推荐

  1. docker debug diagnose

    $ sudo systemctl stop docker $ sudo docker -d -D DEBU[0282] Error contacting registry https://regist ...

  2. MVC HTML辅助类常用方法记录

    (1)@Html.DisplayNameFor(model => model.Title)是显示列名, (2)@Html.DisplayFor(modelItem => item.Titl ...

  3. C++省略参数(va_list va_start va_arg va_end)的简单应用

    原文参考自:http://www.cnblogs.com/hanyonglu/archive/2011/05/07/2039916.html #include <iostream> #in ...

  4. 20145211《Java程序设计》第5周学习总结——独上高楼,望尽天涯路

    教材学习内容总结 异常处理 JAVA异常 异常指不期而至的各种状况,如:文件找不到.网络连接失败.非法参数等.异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程.异常就是出现在运行时出现不正常 ...

  5. Arbitrage---poj2240(floyd)

    题目链接:http://poj.org/problem?id=2240 题意:有n个国家的,有m个关系,每个关系的格式是:A B C表示1单位的A国货币可以换B单位C国货币:求是否存在一种方法使得货币 ...

  6. VMware中CentOS设置静态IP

    因为之前搭建的MongoDB分片没有采用副本集,最近现网压力较大,所以准备研究一下,于是在自己电脑的虚拟机中搭建环境,但是发现之前VMware设置的是DHCP,所以每次重新resume后虚拟机中IP都 ...

  7. 【指标测试】影响IOPS的几个重要因素

    1. 读写方式 顺序读写的IOPS要比随机读写的IOPS高.100%顺序读写来讲,顺序读要高于顺序写.100%随机读写来讲,随机读要高于随机写.小块读写的IOPS要比大块读写高.需要根据实际的应用程序 ...

  8. C#中static静态变量的用法

    使用 static 修饰符声明属于类型本身而不是属于特定对象的静态成员static修饰符可用于类.字段.方法.属性.运算符.事件和构造函数,但不能用于索引器.析构函数或类以外的类型 静态全局变量 定义 ...

  9. FTP文件夹打开错误,Windows无法访问此文件夹

    错误提示: Windows 无法访问此文件夹,请确保输入的文件夹是正确的,并且你有权访问此文件夹.    解决方法/步骤如下    1.请确保输入的文件夹是正确的,并且你有权访问此文件夹.可以在浏览器 ...

  10. Insert BLOB && CLOB from PL/SQL and JDBC

    For PL/SQL 1)Create Directory Where BLOB resides. create or replace directory temp as '/oradata2'; - ...