simple jQuery (check and uncheck)

<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>

posted @ 2011-06-22 18:59  withsoso  阅读(252)  评论(1编辑  收藏  举报