
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery全选和反选功能代码,兼容所有浏览器|www.125jz.com</title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function flowCheck(thisClass){
if($(thisClass).attr("checked")=="checked"||$(thisClass).attr("checked")==true){
$(".controlBox,.flowCheckbox").attr("checked","checked");
}else{
$(".controlBox,.flowCheckbox").attr("checked",false);
}
}
</script>
</head>
<body>
<input type="checkbox" class="controlBox" onclick="flowCheck(this)" />全选<br/>
<hr>
<input type="checkbox" class="flowCheckbox" /> 网页配色<br/>
<input type="checkbox" class="flowCheckbox" /> 网页制作<br/>
<input type="checkbox" class="flowCheckbox" /> JS学习 <br/>
<input type="checkbox" class="flowCheckbox" /> 网页设计<br/>
</body>
</html>
低版本的jquery库支持attr(“checked”)==”checked”的写法,而不支持attr(“checked”)==true的写法。本代码解决了此兼容问题。
125jz网原创文章。发布者:江山如画,转载请注明出处:http://www.125jz.com/4116.html
微信扫一扫
支付宝扫一扫