jquery - Javascript code does not work -


i have panel activated/deactivated checkbox (chk1)'on/off'. panel contains checkbox (chk2) , radio button (rbtn). when radio button (rbtn) checked checkbox must disabled. when panel disabled unchecking 'on/off' checkbox, radio button , checkbox (chk2) disabled. problem when open page panel enabled, code javascript executed, when open page panel disabled, after enabled panel javascript doe not work when check radio button chk2 became disabled.

 $(document).ready(function (){      $('input[id^=rbtn]').click(function () {          setcontrolenablestate($('#chk2'), $('#rbtn'));      });      function setcontrolenablestate(controltoset, control) {          if (control.is(':checked')) {             $(controltoset).attr('disabled', 'disabled');             alert('if');          }          else {             $(controltoset).removeattr('disabled');             alert('else');         }      } }); 

when panel updated javascript code not available anymore.

don't use click event on checkboxes change 1 :

    $('input[id^=rbtn]').change(function () { 

this way you'll new state. click event generated before checkbox changed.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -