日期:2014-05-16  浏览次数:20368 次

ie8 $("input[name=items]").attr("checked",null);不能实现反选?
这个能实现全选啊。求解释。
$("input[name=items]").attr("checked","checked");
百度知道有点删问题。

------解决方案--------------------
$("input[name=items]").attr("checked",false);
看看
------解决方案--------------------
我测试了下,ie8下
$("input[name=items]").attr("checked",null);
也是可以的

<!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>
<script src="jquery-1.7.1.min.js"></script>

<head>
<body>
 <input name=items type=checkbox>
 <input name=items type=checkbox>
 <input name=items type=checkbox>
 <input name=items type=checkbox>
<input type="button" value="selectAll" onclick='$("input[name=items]").attr("checked","checked");'>
<input type="button" value="UnSelectAll" onclick='$("input[name=items]").attr("checked",null);'>
<input type="button" value="UnSelectAll" onclick='$("input[name=items]").attr("checked",false);'>
</body>
</html>
------解决方案--------------------
$("input[name=items]").removeAttr("checked");