simple jQuery (check and uncheck)
2011-06-22 18:59
239 查看
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<style type="text/css">
.class-red{
border: red solid 1px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("input:button").bind("click",click);
});
function click() {
$(".checkbox-group input").each(function(){
if($(this).attr("checked")=="checked"){
$(this).attr("checked","");
$(this).removeClass("class-red");
} else {
$(this).attr("checked","checked");
$(this).addClass("class-red");
}
});
}
</script>
</head>
<body>
<div class="checkbox-group">
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="text"/>
</div>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<input type="button" value="click here!"/>
</body>
</html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<style type="text/css">
.class-red{
border: red solid 1px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("input:button").bind("click",click);
});
function click() {
$(".checkbox-group input").each(function(){
if($(this).attr("checked")=="checked"){
$(this).attr("checked","");
$(this).removeClass("class-red");
} else {
$(this).attr("checked","checked");
$(this).addClass("class-red");
}
});
}
</script>
</head>
<body>
<div class="checkbox-group">
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="checkbox" checked="checked"/>
<input type="text"/>
</div>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<input type="button" value="click here!"/>
</body>
</html>
相关文章推荐
- Handling Checkboxes, Radio Buttons and Select Options in jQuery [转]
- Check/Uncheck all Items in an ASP.NET CheckBox List using jQuery
- Check (Validate) File (Image) Size before upload using JavaScript and jQuery
- Learning JQuery: Better Interaction Design and Web Development with Simple Javascript Techniques
- Javascript Check and Uncheck All Checkboxes
- JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)
- CheckException And UnCheckException in Java
- Simple Long Polling Example with JavaScript and jQuery
- javascript Check All, Uncheck All and check one at least
- JQuery checkbox check/uncheck
- spark 笔记 3:Delay Scheduling: A Simple Technique for Achieving Locality and Fairness in Cluster Scheduling
- [从jQuery看JavaScript]-匿名函数与闭包(Anonymous Function and Closure)
- Some books recommended, and also a simple introduction of myself.
- Using iotop to check I/O and swap
- Upload Files In ASP.NET Core 1.0 (Form POST And JQuery Ajax)
- jquery get min and get max
- redis中使用 check-and-set 操作实现乐观锁
- django-simple-captcha & jquery validate
- [jQuery] simple-disappear (消失的例子)——【转】
- Codeforces Round 389 Div.2 B. Santa Claus and Keyboard Check(模拟)