对于表单元素属性为Boolean值的属性,不能通过attr这个jq方法来设置,
$("input[type='checkbox']").attr("checked", true);
应该使用prop这个方法来设置
$("input[type='checkbox']").prop("checked", true);
否则达不到预想的效果。
对于原生的的设置方式分别对应的方法是:setAttribute()和property(),property也可以设置setAttribute能设置的。