Thanks again but it still to hard for me to run the script if i have several ajax calls, does the obj object (in your code) refreshes when I do ajax calls and there are button of same type in it?
What I want actually.... I have content loaded thru ajax and inside it have buttons and i want to simplify the button's theme, caption and at the same time passing function to the click event. I change my code for better understanding A) in loaded content <a href="#" class="btnA"></a> <a href="#" class="btnB"></a> then after page load, script will execute as follow B) in document.ready() of the loaded content $(".btnA").btnInit("Button A", function () { alert('This is button A'); // do some other action_1 when clicked }); $(".btnB").btnInit("Button B", function () { alert ('This is button B'); // do some action_2 when clicked }); different button has different action then , I have this plugin in a different file C) included in mainpage (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 function passed by the script in B) // }; return this.each(function(caption, action){ obj = $(this); prepare(obj, caption, action); }); }; })(jQuery); Sorry for this hassle.