There must be something special about the checked attribute of a checkbox either at the jQuery level or the DOM level. With this HTML:
<html>
<body>
<input id="cb" type="checkbox" />
</body>
</html>
And this JavaScript:
$(function() {
$("#cb").attr("checked","checked");
alert("Expecting this HTML fragment to have a 'checked' attribute:\n\n"
+ $("body").html());
});
I'm not getting what I expect; if I use an attribute name besides "checked" it works as expected.
The reason I'm trying to get this to work is I need to get the HTML as it exists in a browser DOM and convert it to PDF, so users can get PDF versions of the page as it is as they're looking at it; it's manipulated heavily on the client side, so getting the correct HTML directly from the server is not an easy option.
Here's a working version of the above code: http://jsfiddle.net/pettys/qTfDP/2/