Hi I'm trying to write a JQuery function to;
Change the class of a button with class .load-on-click to be a btn-warning and change the button text to loading
Then, after a timeout, return the button to the previous class it had before it was changed to btn-warning, and return the button text to same text it had before it was changed.
I currently have it working below, but can't get it to return to it's previous class, I've just temporarily set it to btn-primary; if anyone know how I would do this, that would be great, thanks.
jQuery("#ntc-web-main .load-on-click").click(function () {
var buttonText = jQuery(this).text();
jQuery(this)
.text("Loading")
.removeClass(
"btn-default btn-primary btn-success btn-info btn-danger btn-link"
)
.addClass("btn-warning");
//revert to original state,
setTimeout(function () {
jQuery(this)
.text(buttonText)
.removeClass("btn-warning")
.addClass("btn-primary");
}, 10000);
});