单选框 radio

<div class="radio-inline">
<input type="radio" name="killOrder" value="1"/>
<label for="killOrder1">是</label>
</div>
<div class="radio-inline">
<input type="radio" name="killOrder" value="0" checked/>
<label for="killOrder2">否</label>
</div>

1.获取值

$("input[name='killOrder']:checked").val();

$('input:radio:checked').val();

$("input[type='radio']:checked").val();

$(":radio[checked]").each(function(radio){alert($(this).val());

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

$('input:radio:first').attr('checked', 'checked');

$('input:radio:first').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='2']").attr('checked','true');

$("input[value='1']").attr('checked','true');

6.删除Value值为2的Radio

$("input:radio[value='2']").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){

//写入代码

});

9.修改单选框样式

input[type="radio"] + label::before {
    content: "\a0";
    display: inline-block;
    vertical-align: middle;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border-radius: 50%;
    text-indent: .15em;
    margin-bottom: 4px;
    border: 1px solid #CCCCCC;
}
input[type="radio"]:checked + label::before {
    background-color: #4A90E2;
    background-clip: content-box;
    padding: 2px;
}
input[type="radio"] {
    position: absolute;
    clip: rect(0, 0, 0, 0);
}
.radio-inline{
    padding-left: 0;
}
input[type=radio][disabled]:checked + label::before{
    background-color:#CCCCCC;
    background-clip: content-box;
    padding: 2px;

}

单选框radio总结(获取值、设置默认选中值、样式)的更多相关文章

  1. 【jQuery获取下拉框select、单选框radio、input普通框的值和checkbox选中的个数】

    radio单选框:name属性相同 <input type="radio" id="sp_type" name="p_type" va ...

  2. MFC学习单选框Radio使用

    创建单选框Radio ,ID号IDC_RADIO_NAME 1.获取单选框内容 int RadioState = ((CButton *)GetDlgItem(IDC_RADIO_NAME))-> ...

  3. jquery单选框radio绑定click事件实现和是否选中的方法

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: 1. ...

  4. 吾八哥学Selenium(三):操作复选框checkbox/单选框radio的方法

    复选框checkbox和单选框radio是web网站里经常会使用到的两个控件,那么在web自动化测试的时候如何利用Selenium来操作这俩控件呢?今天我们就来简单入门练习一下! html测试页面代码 ...

  5. 自定义单选框radio样式

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. 单选框radio改变事件详解(用的jquery的radio的change事件)

    单选框radio改变事件详解(用的jquery的radio的change事件) 一.总结 1.用的jquery的radio的change事件:当元素的值发生改变时,会发生 change 事件,radi ...

  7. 设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选

    设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选 >>>>>>>>>>>>&g ...

  8. jquery单选框radio绑定click事件实现方法

    本文实例讲述了jquery单选框radio绑定click事件实现方法.分享给大家供大家参考. 具体实现方法如下: 复制代码代码如下: <html><head><title ...

  9. C#通过属性名字符串获取、设置对象属性值

    之前理工项目从这个博客找到了相对应的方法:C#通过属性名字符串获取.设置对象属性值 https://www.cnblogs.com/willingtolove/p/12198871.html

随机推荐

  1. Linux常用基本命令 1

    useradd 创建用户. password 修改密码. date 查看时间 man date 帮助文档.f往后翻 b往前翻 q退出.软修改 man hwclock 修改硬件时钟, cal 查看日历 ...

  2. css一div内文字居中

    在说到这个问题的时候,也许有人会问CSS中不是有vertical-align属性来设置垂直居中的吗?即使是某些浏览器不支持我只需做少许的CSS Hack技术就可以啊!所以在这里我还要啰嗦两句,CSS中 ...

  3. mybatis学习笔记 spring与mybatis整合

    转载自http://blog.csdn.net/naruto_Mr/article/details/48239357 1.创建web工程,导入spring依赖包与mybatis依赖包,还需要mybat ...

  4. ibatis和hibernate

    ibatis:sql需要自己写hibernate:sql自动生成上面是最大的区别,下面是一些细节.选择Hibernate还是iBATIS都有它的道理:Hibernate的特点:Hibernate功能强 ...

  5. [GO]结构体及普通变量初始化

    结构体是一种聚合的数据类型,它是由一系列相同类型或者不同类型的数据构成的数据集合,每个数据称为结构体的成员 1.结构体的初始化 package main import "fmt" ...

  6. [GO]给导入包起别名

    package main import io "fmt" //引用fmt这个包时,名字重命名为io import _ "os" //引用os这个包,但是不调用, ...

  7. Maven 项目使用开源中国镜像

    从maven中央库下载jar非常缓慢甚至有时候会下载不下来. 可以采用中国的maven镜像.目前主要是 开源中国的镜像. 找到maven配置文件setting.xml,打开 中间添加开源中国的配置: ...

  8. 解决linux下80端口占用问题

    在即安装有tomcat,又安装有nginx的服务器上(典型阿里云驻云java镜像),系统默认配置nginx占用80端口,tomcat占用8080端口. 如果想要便于用户可以直接通过IP或者域名访问到t ...

  9. Android内置和外置SD卡的位置获取

    public class StorageUtils { private static String TAG="123"; // 获取主存储卡路径 内置内存卡路径 public st ...

  10. .net Reflection(反射)- 二

    反射 Reflection 中访问方法 新建一个ClassLibrary类库: public class Student { public string Name { get; set; } publ ...