I have the following code (that works) to toggle an iPhone style checkbox:
$('.iphone-style').live('click', function() {
checkboxID = '#' + $(this).attr('rel');
if($(checkboxID)[0].checked == false) {
$(this).animate({backgroundPosition: '0% 100%'});
$(checkboxID)[0].checked = true;
$(this).removeClass('off').addClass('on');
} else {
$(this).animate({backgroundPosition: '100% 0%'});
$(checkboxID)[0].checked = false;
$(this).removeClass('on').addClass('off');
}
});
In a different function, I would like a specific checkbox (AerialView) to be unchecked when another checkbox (PhotoStyles) is unchecked. I don't know how to correctly replace the 'this' reference with something more specific. I have the following (which doesn't work):
if($('#PhotoStylesCheck')[0].checked == false) {
$('#AerialViewCheck').animate({backgroundPosition: '100% 0%'});
$('#AerialViewCheck')[0].checked = false;
$('#AerialViewCheck').removeClass('on').addClass('off');
}
Note that I confirmed that the if statement works and the setting the checked to false also works. The visual elements of 'animate', 'removeClass', and 'addClass' do not work.