$.fn.enable = function() { return this.each( function() { this.onclick = this.clickFn; $(this).text("enable"); }); } $('#testBut').enable();