I want to add an unchecked input to a list and make it so the user can’t check it.
Then I want to set all the check boxes unless they are disabled. The following kind of works but IE9 and FF8 (and probably all other browsers) show the disabled check boxes as shaded checked.
How can I keep the disabled check boxes from appearing checked?
Thanks
<script type="text/javascript">
$(document).ready(function(){
$('#add').click(function(){$('#myList').append($("#clone").clone( true ).removeAttr('id').removeAttr('checked').attr('disabled','disabled'));});
$('#checkIt').click(function(){$('#myList').find('input').attr('checked','checked');});
});
</script>
</head>
<body>
<input id="clone" type="checkbox" checked="checked" name="whatever" value="">
<hr />
<div id="myList">
<input id="normal" type="checkbox" name="whatever" value="123">
</div>
<a href="#" id="add">Add</a>
<a href="#" id="checkIt">Check It</a>
</body>
Should work.
More generally, check out JQuery selectors, they’re awesome:
http://api.jquery.com/category/selectors/