Thanks for the reply but as you can see I need to do initialize something and then hook the click event. The html markup is like this
<a href="#" class="btnA"></a> <a href="#" class="btnB"></a> then after page load, script will execute as follow $(".btnA").btnInit("Button A", function () { do some action 1 }); $(".btnB").btnInit("Button B", function () { do some action 2 }); different button has different action then , I have this plugin (function($){ $.fn.btnInit = function() { function prepare(obj, caption, action) { obj .html(caption) .addClass("fg-button ui-state-default ui-corner-all") .click(function(){ // run the action here when click triggered alert('Do some action');}); }; return this.each(function(caption, action){ obj = $(this); prepare(obj, caption, action); }); }; })(jQuery); Thanks