You need to give class to the button and attach the .on() method with it.
If you have multiple buttons that when you click one, it changes classes & the text inside.
Here is the simple code to do this:
$('.EgClassName').on('click', function(e){
if ($(this).text() == "Any Info")
{
$(this).text("Cancel").addClass('Red-btn');
}
else
{
$(this).text("Any Info").removeClass('Red-btn');
};
});
You just need to bind the click event to all your buttons with the class name that you gave to it. Remember not to give same id to more than one element otherwise it will work for only one that the id will find the first.
0 Comment(s)