JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<div>
<button class='btn btn-success' id='my-btn'>
Open
</button>
</div>
JavaScript
$('#my-btn').click(function(){
$(this).removeClass('btn-success');
$(this).addClass('btn-danger');
$(this).html('Close');
});
$('.btn-danger').click(function(){
alert('hello world');
$(this).removeClass('btn-danger');
$(this).addClass('btn-success');
$(this).html('Open');
});