Question: Fiddle - <http://jsfiddle.net/XH5zm/>  

JSBin - <http://jsbin.com/UKIweJE/1/edit>

I'm trying to enable/disable an input textbox by toggling if a checkbox is checked or not.

```
$(document).ready(function() {
  if ($('.enable-padding').attr('checked') === true) {
    $('.grab-padding').attr('enabled','enabled');
    $('.grab-padding').val("13px");
  } else {
    $('.grab-padding').attr('disabled','disabled');
    $('.grab-padding').val(" ");
  }
});

```

What exactly am I'm doing wrong? 

Any help is greatly appreciated.

Answer: 
You have to add an event for change the state of checkbox:

```
$(document).ready(function() {
  $('.enable-padding').on('change',function(){
    if ($('.enable-padding').is(':checked')) {
    $('.grab-padding').removeAttr('disabled');
    $('.grab-padding').val("13px");
  } else {
    $('.grab-padding').attr('disabled','disabled');
    $('.grab-padding').val(" ");
  }
  });
});

```

and modifiy the input for this:

```
<input class="grab-padding" type="text" value="13px"></td>

```
```
$('#chbox').click(function () {
  if ( $('#txt_data').attr('disabled') =='disabled' ){
      $('#txt_data').removeAttr('disabled');
  }else{
         $('#txt_data').attr('disabled','disabled');
  }

});

```