javascript - Checkbox state change detection -


i have scenario in showing/hiding portion of screen depending on whether check box checked or now.

so catch here that, not user changing state of check box, programmatically.

so how detect change , when ever state of check box changed , want section hidden or shown.

presently doing this...

    externalcheckboxclicked : function (e){         var $target = $(e.target),           checked = $target.prop('checked');          if(checked){             $('#confirm-button').show();         }else{             $('#confirm-button').hide();         }     }      settoprevioussetvalues : function(){         if(this.requestdata.isoverrideexternalparams === "1"){             $('#externalparameterschkbox').prop('checked',true);         }else {             $('#externalparameterschkbox').prop('checked',false);         }     },     events: {        "change #externalparameterschkbox":"externalcheckboxclicked",     }, 

any clue why not working.

you can try one:

$(".checkbox").change(function() {     if(this.checked) {         //do stuff     } }); 

you can add .checkbox place class file or id file


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -