Jquery获取radio选中的值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="" />
  <style type="text/css"></style>
  <script type="text/javascript" src="jquery-3.0.0.js"></script>
 </head>

 <body>
  <input type="radio" name="radio" value="1" />1<br/>
  <input type="radio" name="radio" value="2" />2<br/>
  <input type="radio" name="radio" value="3" />3<br/>
  <input type="radio" name="radio" value="4" />
  <script type="text/javascript">
    var a = $("input[name=‘radio‘]:checked").val();
    alert("选中的radio的值是:" + a);
</script>
 </body>
</html>
时间: 2024-07-29 19:45:18

Jquery获取radio选中的值的相关文章

jquery获取radio选中的值或者select做出判断事件

<dl class="clearfix" id="shifou"> <dt>是否已报名:</dt> <dd><input type="radio" name='sf' value='1'>已报名    <input type="radio" name='sf' value='0'>未报名(有意向)</dd> </dl> <dl

jquery获取单选按钮选中的值

在页面上单选按钮的代码: <s:iterator value="@[email protected]"> <input type="radio" <s:if test="key eq record.is_com">checked</s:if> value="${key}" name="record.is_com"/>${value}    </s:ite

IE8下Jquery获取select选中的值的问题

我们一般使用jquery获取select时,一般这么用: <select id='a'>     <option selected='selected' value='1'> </select> var selectedValue = $("#a").val(); 在非IE8下,selectedValue的值为"1",typeof selectedValue 为"string". 在IE8下,selectedV

jQuery获取checkbox选中的值

1.问题背景 有几个多选框,选择其中的几个,获取选中的值 2.设计源码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>

jQuery获取radio选中后的文字

原文链接:http://blog.csdn.net/zhanyouwen/article/details/51393216 jQuery获取radio选中后的文字转载 2016年05月13日 10:32:14 标签:jQuery获取radio选中后的文字 850 HTML 示例如下: [html] view plain copy<input type="radio" id="male" name="sex" value="1&qu

jquery获取select选中的值并对另一个select禁用启用

误区: 一直以为jQuery获取select中option被选中的文本值,是这样写的: $("#s").text();  //获取所有option的文本值 实际上应该这样: $("#s option:selected").text();  //获取选中的option的文本值 获取select中option的被选中的value值, $("#s").val(); $("#s option:selected").val(); js获

jquery怎么获取radio选中的值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

jQuery获取radio选中项的值【转藏】

<title></title> <script src="js/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function () { //没有默认选中的情况 //先判断radio是否有选中项,再获取选中的值 $("#btnclick").click(function () { //获取选中项的valu

Jquery 获取 radio选中值

Radio 1.获取选中值,三种方法都可以: $('input:radio:checked').val(): $("input[type='radio']:checked").val(); $("input[name='rd']:checked").val(); 2.设置第一个Radio为选中值: $('input:radio:first').attr('checked', 'checked'); 或者 $('input:radio:first').attr('ch