jquery获取radio值(单选组radio)_javascript技巧

单选组radio: $("input[@type=radio][@checked]").val();

单选组radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

获取一组radio被选中项的值

var item = $('input[@name=items][@checked]').val();

radio单选组的第二个元素为当前选中值

$('input[@name=items]').get(1).checked = true

单选组 radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

jquery老的版本

var_name = $("input[@name='radio_name']:checked").val();

jquery 1.3以后的版本

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

看个获取radio值的jquery实例

function getra(){

var_name = $("input[name='isspecialcnt']:checked").val();
//alert(var_name);
if(var_name=='1'){
$("#isspecialcntyes").show();
$("#isspecialcntno").hide();
}
if(var_name=='0'){
$("#isspecialcntyes").hide();
(www.jb51.net) $("#isspecialcntno").show();
}
}

<form name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_0">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_1">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_2">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_3">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_4">
单选</label>
<br>
<label>
<input type="radio" name="radiogroup1" value="单选" id="radiogroup1_5">
单选</label>
<br>
</p>
</form>

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索radio值
jquery radio 单选、radio 单选、asp radiobutton 单选、input radio单选框、input radio 单选,以便于您获取更多的相关知识。

时间: 2024-08-04 07:04:33

jquery获取radio值(单选组radio)_javascript技巧的相关文章

javascript/jquery获取地址栏url参数的方法_javascript技巧

使用jquery获取url以及使用jquery获取url参数是我们经常要用到的操作 1.jquery获取url很简单,代码如下 复制代码 代码如下: window.location.href;  其实只是用到了javascript的基础的window对象,并没有用jquery的知识 2.jquery获取url参数比较复杂,要用到正则表达式,所以学好javascript正则式多么重要的事情 首先看看单纯的通过javascript是如何来获取url中的某个参数 复制代码 代码如下: function

javascript获取select值的方法分析_javascript技巧

本文实例讲述了javascript获取select值的方法.分享给大家供大家参考.具体分析如下: 1. 获取显示的汉字 复制代码 代码如下: document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text 2. 获取数据库中的id 复制代码 代码如下: window.document.getElementById(&q

javascript使用for循环批量注册的事件不能正确获取索引值的解决方法_javascript技巧

本文实例讲述了javascript使用for循环批量注册的事件不能正确获取索引值的解决方法.分享给大家供大家参考.具体分析如下: 可能不少朋友会遇到一个问题,那就是当使用for循环批量注册事件处理函数,然后最后通过事件处理函数获取当前元素的索引值的时候会失败,先看一段代码实例: 复制代码 代码如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name=&q

jQuery获取及设置单选框实例介绍

单选组radio: $("input[@type=radio][@checked]").val(); 获取一组radio被选中项的值 var item = $("input[@name=items][@checked]").val(); 获取select被选中项的文本 var item = $("select[@name=items] option[@selected]").text(); select下拉框的第二个元素为当前选中值 $(&quo

jquery获取元素值的方法(常见的表单元素)_jquery

jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $('input[name=items][checked]').val(); 获取select被选中项的文本 var item = $("select[name=items] option[selected]").text(); select下拉框的第二个元素为当前选中值 $('#select_id

jquery获取元素值

jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $('input[name=items][checked]').val(); 获取select被选中项的文本 var item = $("select[name=items] option[selected]").text(); select下拉框的第二个元素为当前选中值 $('#select_id

jquery 获取input值

该获取的是一个jquery对象,而不是一个dom element对象.value是dom element对象的属性.所以,使用 获取值: 文本框,文本区域: $("#txt").attr("value"): $("#txt").val(); 多选框checkbox: $("#checkbox_id").attr("value"): 单选组radio: $("input[@type=radio][@

jQuery获取cookie值及删除cookie用法实例_jquery

本文实例讲述了jQuery获取cookie值及删除cookie用法.分享给大家供大家参考,具体如下: cookie在jquery中有指定的cookie操作类,这里先来介绍在使用cookie操作类时的一些问题,然后介绍正确的使用方法. 使用JQuery操作cookie时 发生取的值不正确的问题: 结果发现cookie有四个不同的属性: 名称,内容,域,路径 $.cookie('the_cookie'); // 读取 cookie $.cookie('the_cookie', 'the_value'

textfield-Ext.net Jquery获取TextField值

问题描述 Ext.net Jquery获取TextField值 @( X.Window() .Title("这是添加页面") .Width(400) .Height(400) .Layout("FitLayout") .AutoShow(true) .Items( X.FormPanel() .ID("PanelForm") .BodyPadding(5) .Items( X.TextField() .ID("txtName"