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
Post a Comment