JSFiddle - React, Tailwind, and code Playground
HTML
<form class="follow-form" method="post" action="listen.php">
<input name="followID" value="123456" type="hidden">
<button type="submit" value="Actions" class="btn follow" title="123456">
<i></i><span>follow</span>
</button>
</form>
JavaScript
jQuery(function($) {
$("form.follow-form").submit(function(e) {
e.preventDefault();
$(this).find('i').addClass('active');
$.post('/ajax_html_echo/', {
followID: $(this).find('input').val()
}, function() {
$(e.currentTarget).find('button').hide().after('<span class="following">Following!</span>');
});
});
});