radio 获取选中值

摘要:
Radio1.获取选中值,三种方法都可以:123$('input:radio:checked').val();$("input[type='radio']:checked").val();$("input[name='rd']:checked").val();2.设置第一个Radio为选中值:123$('input:radio:first').attr('checked','checked');或

Radio

radio 获取选中值第1张

radio 获取选中值第2张

1.获取选中值,三种方法都可以:

1
2
3
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();

2.设置第一个Radio为选中值:

1
2
3
$('input:radio:first').attr('checked', 'checked');
或者
$('input:radio:first').attr('checked', 'true');

注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)

3.设置最后一个Radio为选中值:

1
2
3
$('input:radio:last').attr('checked', 'checked');
或者
$('input:radio:last').attr('checked', 'true');

4.根据索引值设置任意一个radio为选中值:

1
2
3
$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).attr('checked', 'true');

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

1
2
3
$("input:radio[value=//www.jb51.net/kf/201110/'rd2']").attr('checked','true');
或者
$("input[value=//www.jb51.net/kf/201110/'rd2']").attr('checked','true');

6.删除Value值为rd2的Radio

1
$("input:radio[value=//www.jb51.net/kf/201110/'rd2']").remove();

7.删除第几个Radio

1
2
$("input:radio").eq(索引值).remove();索引值=0,1,2....
如删除第3个Radio:$("input:radio").eq(2).remove();

8.遍历Radio

1
2
3
$('input:radio').each(function(index,domEle){
//写入代码
});

DropDownList

radio 获取选中值第3张

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为选中值

免责声明:文章转载自《radio 获取选中值》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇SQL中连接(JOIN)子句介绍操作系统-进程(5)进程通信机制下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

2-14-1 MySQL基础语句,查询语句

一. SQL概述 结构化查询语言(Structured Query Language)简称SQL 1. 它是一种特殊目的的编程语言 2. 它还是一种数据库查询和程序设计语言 (用于存取数据以及查询、更新和管理关系数据库系统;同时也是数据库脚本文件的扩展名) 从上可以看出我们数据库相关工作职位大概两种:DBD和DBA SQL 是1986年10 月由美国国家标...

oracle sqlplus及常用sql语句

常用sql语句 有需求才有动力 http://blog.csdn.net/yitian20000/article/details/6256716 常用sql语句 创建表空间:create tablespace 表空间名字 filedata 'd:db.dbf' size 20m uniform size 128k;说明:创建一个20M的表空间,且表空间的区...

pytorch中torch.unsqueeze()函数与np.expand_dims()

numpy.expand_dims(a, axis) Expand the shape of an array. Insert a new axis that will appear at the axis position in the expanded array shape.   Parameters: a : array_like...

调用支付宝转账接口(单笔)

下面这几个类都是支付宝demo里面的,直接拿过来用就可以 using System.Web; using System.Text; using System.IO; using System.Net; using System; using System.Collections.Generic; namespace Com.Alipay { pu...

三, 用户管理 一

用户概念 一、sys用户和system用户 Oracle安装会自动的生成sys用户和system用户 (1)、sys用户是超级用户,具有最高权限,具有sysdba角色,有create database的权限,该用户默认的密码是change_on_install (2)、system用户是管理操作员,权限也很大。具有sysoper角色,没有create...

sql语句的join用法

sql的join分为三种,内连接、外连接、交叉连接。 以下先建2张表,插入一些数据,后续理解起来更方便一些。 create table emp(empno int, name char(20),depart int);create table depart(dpno int,dpname char(20));insert into emp values (...