In my quest for a simple feedback mechanism, I want to create an effect where pressing a button will quickly fade it out, change its class and content, then fade it back in before reverting to its original state.
Here is the code snippet that I believed would accomplish this task:
$('#event1-btn-451').fadeOut(200).toggleClass('btn-primary btn-success').html('Success!').fadeIn(200);
$('#event1-btn-451').delay(2000).fadeOut(200).toggleClass('btn-success btn-primary').html('Add Event').fadeIn(200);
While the first line works as expected, including the second line causes the button to simply fade out, then fade in with the 'Add Event' text in its original color, repeating the process after a 2-second delay.
This is my first time posting here, although I have found answers on this platform countless times before!