单选框radio总结(获取值、设置默认选中值、样式)
单选框 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总结(获取值、设置默认选中值、样式)的更多相关文章
- 【jQuery获取下拉框select、单选框radio、input普通框的值和checkbox选中的个数】
radio单选框:name属性相同 <input type="radio" id="sp_type" name="p_type" va ...
- MFC学习单选框Radio使用
创建单选框Radio ,ID号IDC_RADIO_NAME 1.获取单选框内容 int RadioState = ((CButton *)GetDlgItem(IDC_RADIO_NAME))-> ...
- jquery单选框radio绑定click事件实现和是否选中的方法
使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: 1. ...
- 吾八哥学Selenium(三):操作复选框checkbox/单选框radio的方法
复选框checkbox和单选框radio是web网站里经常会使用到的两个控件,那么在web自动化测试的时候如何利用Selenium来操作这俩控件呢?今天我们就来简单入门练习一下! html测试页面代码 ...
- 自定义单选框radio样式
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 单选框radio改变事件详解(用的jquery的radio的change事件)
单选框radio改变事件详解(用的jquery的radio的change事件) 一.总结 1.用的jquery的radio的change事件:当元素的值发生改变时,会发生 change 事件,radi ...
- 设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选
设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选 >>>>>>>>>>>>&g ...
- jquery单选框radio绑定click事件实现方法
本文实例讲述了jquery单选框radio绑定click事件实现方法.分享给大家供大家参考. 具体实现方法如下: 复制代码代码如下: <html><head><title ...
- C#通过属性名字符串获取、设置对象属性值
之前理工项目从这个博客找到了相对应的方法:C#通过属性名字符串获取.设置对象属性值 https://www.cnblogs.com/willingtolove/p/12198871.html
随机推荐
- 04.webservice客户端调用
不要求所有的元素都理解,真正做开发的时候,有一些必须是要用的. 以后我们做开发的时候服务访问点的集合就一个服务的访问点.服务访问点绑定了具体的一个服务类,绑定的这个东西它本身也是一个元素.往上找,四个 ...
- 696. Count Binary Substrings统计配对的01个数
[抄题]: Give a string s, count the number of non-empty (contiguous) substrings that have the same numb ...
- sfidsk创建可启动分区问题
前言 由于工作上需要经常要为嵌入式设备制作启动SD卡,因此本人使用sfdisk编写了自动分区.格式化和安装文件的脚本.(不选择fdisk是因为它是为用户交互设计的,在脚本上使用不够方便) 实际使用过程 ...
- Windows cmd 快捷操作
复制当前文件夹下符合条件的文件名字到文件 dir /B *-gd.dll > debug /B是只显示文件名,不包含所在路径 复制当前文件夹下文件到另外的地方 xcopy /s/d *-gd.d ...
- 数字图像处理实验(11):PROJECT 05-02,Noise Reduction Using a Median Filter 标签: 图像处理MATLAB 2017-05-26 23:
实验要求: Objective: To understand the non-linearity of median filtering and its noise suppressing abili ...
- python3--列表生成式
# Auther: Aaron Fan # 原始的写法:a = []for i in range(10): a.append(i*2)print(a) # 用列表生成式完成上面的写法:a = [i*2 ...
- Python基础-3
目录 1. 函数基本语法及特性 2. 参数与局部变量 3. 返回值 知识插入:嵌套函数 4.递归 5.匿名函数 6.函数式编程介绍 7.高阶函数 8.内置函数 一.函数基本语法 函数是什么? 函数一词 ...
- Qt工程文件Pro介绍(转)
转载请注明:http://blog.163.com/hu_cuit/blog/static/122849143201127104232142/ 我也才开始学习QT的菜鸟.但是前几天有同学叫我给他讲一下 ...
- struts2 、mybatis 、easyui 分页
rows page 控件自动提交这两个参数 pageSize number The page size. 10pageNumber number Show the page number when p ...
- Debian7安装后的配置(英文环境chromium浏览器中汉字变成方块的问题)
原文来自:http://www.programgo.com/article/3272573017/ 1.安装文泉宋体 sudo aptitude install xfonts-wqy sudo apt ...