I am all set. Figured it out. It does take some getting used to, but seems to be quite similar to Java:
jQuery.fn.toggleOpposite = function(readonly) { if (readonly && this.val().length > 0) { // reset the value to null this.val(''); } return this.attr('disabled',readonly).css('opacity', readonly ? 0.5 : 1.0).focus(); };