单选框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
随机推荐
- 证明3|n(n+1)(2n+1)
[证明3|n(n+1)(2n+1)] n(n+1)(2n+1) => n(n+1)(n+2+n-1) => n(n+1)(n+2) + n(n+1)(n-1) 因为n(n+1)(n+2). ...
- MyBatis之 逆向工程生成代码
逆向工程: 所谓mybatis逆向工程,就是mybatis会根据我们设计好的数据表,自动生成pojo.mapper以及mapper.xml. 工程简单案例: 1,新建一个java项目,把需要使用的ja ...
- 在aspx页动态加载ascx页面内容,给GridView控件绑定数据
在aspx页动态加载ascx页面内容 //加载ascx页面内容Control c1 = this.Page.LoadControl("WebUserControl1.ascx"); ...
- string基本字符系列容器(一)
C++STL提供了string基本字符系列容器来处理字符串,可以把string理解成字符串类,它提供了添加,删除,替换,查找和比较等丰富的方法. 使用string容器,需要头文件包含声明#includ ...
- MockWebServer使用指南
转载请标明出处:http://blog.csdn.net/shensky711/article/details/52771797 本文出自: [HansChen的博客] MockWebServer介绍 ...
- C语言代码里不能用goto?
当我学C语言时,老师整天告诉我:"不要使用goto, 这是一个坏习惯, 这种写法很烂,而且很危险!"等等. 但是为什么那么多内核程序员那么喜欢用goto呢? 在这段linux内核 ...
- c# 下实现ping 命令操作
1>通过.net提供的类实现 using System; using System.Collections.Generic; using System.Linq; using System.Te ...
- 解决error C2365
今天把一个FILE_BOTH_DIRECTORY_INFORMATION结构的变量,愣是写成了“enum”枚举....然后出现error C2365错误. 在CSDN上看到别人遇到问题,有人回复了“如 ...
- 25.AVG 函数
定义和用法 AVG 函数返回数值列的平均值.NULL 值不包括在计算中. SQL AVG() 语法 SELECT AVG(column_name) FROM table_name SQL AVG() ...
- Logistic Regression 用于预测马是否生病
1.利用Logistic regression 进行分类的主要思想 根据现有数据对分类边界线建立回归公式,即寻找最佳拟合参数集,然后进行分类. 2.利用梯度下降找出最佳拟合参数 3.代码实现 # -* ...