Hi, after some painful debugging, I determined that there is a bug in
the jQuery FAQs about how to clear a checkbox.  Specifically, if you
have a strict XHTML document, you *cannot* use .attr("checked","") to
clear a checkbox. Instead, you must use .removeAttr("checked").  See
the following PHP code sample:


<?
        header('Content-type: application/xhtml+xml');
        print '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Checkbox test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3/jquery.min.js"></script>
</head>
<body>
<p>
<input type="checkbox" id="c"/> I'll be checked/unchecked.
<input type="button" value="Check" onclick='$("#c").attr
("checked","checked")'/>
<input type="button" value="Uncheck - fail" onclick='$("#c").attr
("checked","")'/>
<input type="button" value="Uncheck - good" onclick='$("#c").removeAttr
("checked")'/>
</p>
</body>
</html>


I have updated the FAQ accordingly. Hope this helps.

Reply via email to