jquery radio 取值 取消选中 赋值

时间:2022-09-17 17:39:36
<!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-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.11.1.min.js"> </script>
<script>
$(function() {
$("#studentBtn").click(function() {
//var student = $("#student").val();//不管选没选中,只取第一个
//var student = $("#student:checked").val();//取选中项
//$("#student:checked").attr("checked",false);//取消选中项
//$("#student:eq(3)").attr("checked",true);//指定选中项(无效)
//$("#student[value=2]").attr("checked",true);//指定选中项(IE8有效,谷歌不可用,qq(IE10内核)不可用,火狐无效)
//$("#student[type=radio]:eq(2)").attr("checked",true);//指定选中项选中
//$("#student[value=2]").attr("checked",true);//指定值的项选中(无效)
//$("input[id=student][value=2]").attr("checked",true);//指定值的项选中
//var studentNo = $("#studentNo").val();
//$("#student:checked").attr("checked",false);
//指定值的项选中(1、IE下可用(IE8内核) 2、谷歌下可用 3、QQ(IE10内核)下只有第一次执行成功,第二次无效 4、火狐下无论多少次无效)
//$("input[type=radio][name=student][value='"+$("#studentNo").val()+"']").attr("checked",true);
//alert(student);
});
})
</script>
</head> <body>
<input name="student" id="student" type="radio" value="0" />张飒
<input name="student" id="student" type="radio" checked="checked" value="1" />李斯
<input name="student" id="student" type="radio" value="2" />王武
<input name="student" id="student" type="radio" value="3" />赵丽 输入学号:
<input type="text" name="studentNo" id="studentNo" value="0" />
<input type="button" name="studentBtn" id="studentBtn" onclick="chooseStudent()" value="确定" />
</body>
</html>

jquery radio 取值 取消选中 赋值的更多相关文章

  1. jquery radio取值,checkbox取值,select取值及选中

    jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $('in ...

  2. jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中

    jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); //为Se ...

  3. jQuery radio取值,checkbox取值,select取值

    语法解释: $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发 var checkTex ...

  4. 2016 系统设计第一期 (档案一)jQuery radio 取值赋值

    MVC代码: <div class="form-group"> <label for="Gender" class="col-sm- ...

  5. easyui 》 radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中

    获取一组radio被选中项的值var item = $('input[@name=items][@checked]').val();获取select被选中项的文本var item = $(" ...

  6. jquery select取值,赋值操作

    select">jquery select取值,赋值操作 一.获取Select 获取select 选中的 text : $("#ddlRegType").find( ...

  7. 能取值亦能赋值的Python切片

    切片,就像面包,给几刀,切成一片一片,可以做成吐司,也可以做成三明治,口味更佳: 列表(list).元组(tuple).字符串(str)都能进行切片,得到子片段,实际上切片操作比想象的要强大很多,能取 ...

  8. Jquery常用radio取值&comma;checkbox取值&comma;select取值&comma;radio选中&comma;checkbox选中&comma;select选中&comma;及其相关设置

    获取一组radio被选中项的值:var item = $('input[name=items][checked]').val(); 获取select被选中项的文本:var item = $(&quot ...

  9. jsp之radio取值与赋值

    转自:https://blog.csdn.net/dongfengkuayue/article/details/50352937 取radio的值: js代码 $("input[name=' ...

随机推荐

  1. 【Android】Android Studio 进行代码混淆,打包release APK

    整了一天,感觉坑挺多. 1. 选择如图中的选项Android Studio进行签名打包: 2. 填写APP对应的信息:(最好用个文本记下来放在项目中同步给Team) - Key store path: ...

  2. 两个Canvas小游戏

    或许连小游戏都算不上,可以叫做mini游戏. 没有任何框架或者稍微有点深度的东西,所以有js基础的或者要追求炫酷效果的可以直接ctrl+w了. 先贴出两个游戏的试玩地址: 是男人就走30步 是男人就忍 ...

  3. js-方法

    最近觉得自己的基础貌似太薄弱了,找了几本电子书,整理了一下基础的 方法: Concat:返回一个新数组 var a=['a','b','c']; var b=['x','y','z']; var c= ...

  4. BZOJ4026&colon; dC Loves Number Theory

    Description  dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯 竭的水题资源.    给定一个长度为 n的正整数序列A,有q次询问,每次询问一段区间内所 ...

  5. Key Task

    Problem Description The Czech Technical University is rather old - you already know that it celebrat ...

  6. Linux企业级开发技术(4)——epoll企业级开发之epoll例程

    为了使大家更加深入了解epoll模型在企业应用中的使用,下面给出一段基于epoll的服务器代码,并在代码中添加了详细注释: #include <deque> #include <ma ...

  7. (转)asp&period;net注册实现下一步

    在asp.net中有两种容器控件,其中包括panel和placeholder控件. 使用panel控件可以对控件进行分组.一帮助组织web窗体也的内容,将控件组织在面板中,可提供有关在运行时控件应如何 ...

  8. 未完成的IT路停在回车键---2014年末总结篇

    时间都去哪儿了?         一晃而过,越来越能体会到这个词的真实感.特别是过了二十岁,这种感觉越来越深刻,越来越强烈,犹如小编做公交车的时候一直向后排排倒的香樟树,还记得有首歌叫时间都哪儿了,而 ...

  9. calss 类

    class Role(object): n = 123 # 类变量,像__init__中life_value,money默认参数用类变量,如果多个类的实例那就节省了内存,类变量只在类中存一份,实例中不 ...

  10. Ubuntu LNMP系统搭建Zabbix监控

    系统环境 操作系统类型:Ubuntu 系统环境版本:4.4.0-122-generic IP地址:192.168.152.118 第一步:选择适当的操作系统类型与各项的版本要求,我这边直接使用LNMP ...