I need to create a generic function that I can apply to all my buttons that adds a loader image into the button by adding a class to the button when clicked and hides the image once whatever function the button triggered has returned.
How could I do this using jQuery?
This is the code I've got so far.
var B ={
addSpinner: function () {
$(this).click(function(){
$(this).addClass('.spinner');
});
}
};
Am I using this
correctly to select the clicked button?
Would it be good practice to have another function to remove the class once the function the button triggered returned, or would it be better to have this in the addSpinner
function?
How do I listen for the that event?
Thanks