this - JQuery checkbox object reference -


i have following code (that works) toggle 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 different function, specific checkbox (aerialview) unchecked when checkbox (photostyles) unchecked. don't know how correctly replace 'this' reference more specific. have 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 confirmed if statement works , setting checked false works. visual elements of 'animate', 'removeclass', , 'addclass' not work.

if have id of checkbox, syntax checking whether checked or not :

if($('#' + id).is(":checked")) {    // checked } else {    // not checked } 

in case not using correct syntax checking checkbox, , getting 'true' value. ok.

now if $('#aerialviewcheck')[0] checkbox element, apply animate, addclass, removeclass on itself. why trying apply on $('#aerialviewcheck') ? use :

$('#aerialviewcheck')[0].animate({backgroundposition: '100% 0%'}); $('#aerialviewcheck')[0].removeclass('on').addclass('off'); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -