您的位置:首页 > Web前端 > JQuery

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: