1//jQuery 1.6+ use
2$('.checkbox').prop('checked', true);
3//jQuery 1.5.x and below use
4$('.checkbox').attr('checked', true);
1//using plane javascript
2if(document.getElementById('on_or_off_checkbox').checked) {
3 //I am checked
4}
5
6//using jQuery
7if($('#on_or_off_checkbox').is(':checked')){
8 //I am checked
9}
1$( "SELECTOR" ).attr( "checked" ) // Returns ‘true’ if present on the element, returns undefined if not present
2$( "SELECTOR" ).prop( "checked" ) // Returns true if checked, false if unchecked.
3$( "SELECTOR" ).is( ":checked" ) // Returns true if checked, false if unchecked.
1//jQuery 1.6+ use:
2$('.checkboxClass').prop('checked', true);
3//jQuery 1.5.x and below use:
4$('.checkboxClass').attr('checked', true);