单选框 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. 【原创】3. MYSQL++ Query类型与SQL语句执行过程(非template与SSQLS版本)

    我们可以通过使用mysqlpp:: Query来进行SQL语句的增删改查. 首先来看一下mysqlpp::Query的一些最简单的调用, conn.connect(mysqlpp::examples: ...

  2. Java,Calendar -- 获取当前日期、当月月初日期、月末日期

    public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = ...

  3. ArcEngine开发遇到的问题(转)

    ArcEngine开发遇到的问题 https://blog.csdn.net/u013751758/article/category/6971559 转载 2018年02月11日 17:28:11 1 ...

  4. Hadoop完全分布式环境搭建(四)——基于Ubuntu16.04安装和配置Hadoop大数据环境

    [系统环境] [安装配置概要] 1.上传hadoop安装文件到主节点机器 2.给文件夹设置权限 3.解压 4.拷贝到目标文件夹 放在/opt文件夹下,目录结构:/opt/hadoop/hadoop-2 ...

  5. CMakefile for Cross-Platform Compling - 1

    cmake可以自动侦测目标系统,通常编译时候包含的文件和链接的库都不是本地的文件. Demo #toolchain cmake file SET(CMAKE_SYSTEM_NAME Linux) SE ...

  6. jQuery 2.1.4版本的源码分析

    jQuery 2.1.4版本的源码分析 jquery中获取元素的源码分析 jQuery.each({// 获取当前元素的父级元素 parent: function(elem) { var parent ...

  7. hdu 4681 String(转载)

    #include <stdio.h> #include <string.h> #include <algorithm> #include <iostream& ...

  8. JSP内置对象与servlet对应关系

    隐式对象 说明 out 转译后对应JspWriter对象,其内部关联一个PringWriter对象 request 转译后对应HttpServletRequest/ServletRequest对象 r ...

  9. [GO]数组指针做函数参数

    package main import "fmt" //p指向实现数组a,它是指向数组,它是数组指针//*p指向指针指向的内存,就是实参a func modify1(p *[]in ...

  10. Linux基础-工作中经常使用到的linux 命令

     linux 常用命令 (1)命令ls——列出文件 ls -la 给出当前目录下所有文件的一个长列表,包括以句点开头的“隐藏”文件 ls a* 列出当前目录下以字母a开头的所有文件 ls -l *.d ...