Here is function that I wrote:

jQuery.fn.toggleOpposite = function(readonly)  {
  return this.attr('disabled',readonly).css('opacity', readonly ?
0.5 : 1.0).focus();
};

I want to extend it so that it not only toggles the 'disabled'
attribute based on readonly paramater's value but also clears out the
value of the attributes if the readonly parameter's value is 'true'.
Here is an example of call from one of my Rails forms to clarify my
question:

<script>
  $(function() {
    $('#business_send_email').click(function() {
      $('#business_subject').toggleOpposite(!this.checked)
    });
  });
</script>

I am struggling with the jQuery syntax and hence the question.

Thanks.

Bharat

Reply via email to