For some reason this is not working. Instead it thinks it should check the checkbox rather than find out if the box is checked. Can anyone see where I have g开发者_如何转开发one wrong.
if ($('#OPT2checked').attr('checked','checked')) {
var OPT2checked = 'checked="checked"';
} else {var OPT2checked = ''};
Any ideas?
Marvellous,
Try this :)
if ($('#OPT2checked').is(':checked')) {
// Your thing
}
$('#OPT2checked').attr('checked','checked')
sets the attribute 'checked' to 'checked'
$('#OPT2checked').attr('checked')
returns the value of the checked attribute.
By the way, you should test if the checked attribute is defined and not if it has a specific value.
精彩评论