惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
J
Java Code Geeks
A
About on SuperTechFans
F
Fortinet All Blogs
B
Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园_首页
博客园 - 叶小钗
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
云风的 BLOG
云风的 BLOG

博客园 - Xia.CJ

C# 委托 node.js中连接mongodb(Please ensure that you set the default write...)解决办法 node.js api解读之file system模块 Node.js小技巧 在windows上安装新版node.js-node.js学习笔记 Asp.Net MVC部暑托管服务器iis7提示403错误解决方法 mvc3中使用unobtrusive时,ajax更新加载页面后验证失效解决方法 ashx中使用HttpContext.Current.Session ,出现未将对象引用设置到实例上 搜索引擎(google/百度)高级指令 在mvc3中使用uploadify上传组件User.isAuthenticated等于false解决方法 MVC中用Html.RenderPartial还是Html.RenderAction或者Html.Partial-Xia.CJ 在_Layout使用Html.RenderAction的问题-MVC3(Razor)问题 无法删除此对象,因为未在 ObjectStateManager 中找到它-entity framework删除时 Javascript数组(array)操作 序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用 entity framework(EF)_code first复杂类型(Complex Types)问题 entity framework多对多关系查询 JQuery操作Select JQuery动态创建DOM、表单
JQuery获取checkbox值,checkbox全选,操作checkbox
Xia.CJ · 2011-09-30 · via 博客园 - Xia.CJ

JQuery获取checkbox值,checkbox全选,操作checkbox

别忘记引用JQuery包

<!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=utf-8" />
<title>JQuery 操作 checkbox</title>
<script type="text/javascript" src="../jquery-1.6.1.min.js"></script>
<script type="text/javascript" language="javascript">
/*------判断radio是否有选中,获取选中的值--------*/
$(function(){
/*-----全选-----*/
$('#rdo_checked_all').click(function(){
var is_checked=$('#rdo_checked_all').attr('checked');
if(is_checked=="checked"){
$('input[name=color]').attr('checked',true);
}
else{
$('input[name=color]').attr('checked',false);
}
});
$('#btn_getValue').click(function(){
//这里我们获取input为checkbox,name为color而且是选中的,很容易理解不是?
$('input:checkbox[name=color][checked]').each(function(){
var scolor=$(this).val();
alert(scolor);
});
});
});//document ready
</script>
</head>

<body>
<br />
<input type="checkbox" name="display" id="rdo_checked_all"/><label for="rdo_checked_all" >全选</label><br />
<label>红:<input type="checkbox" name="color" value="red" id="rdo_red"/></label>
<label>黄:<input type="checkbox" name="color" value="yellow" id="rdo_yellow"/></label>
<label>蓝:<input type="checkbox" name="color" value="blue" id="rdo_blue"/></label>
<label>绿:<input type="checkbox" name="color" value="green" id="rdo_green"/></label>
<label>黑:<input type="checkbox" name="color" value="black" id="rdo_black"/></label><br />
<input type="button" id="btn_getValue" value="获取选中值" />
</body>
</html>

posted @ 2011-09-30 15:30  Xia.CJ  阅读(4287)  评论()    收藏  举报