JSFiddle - React, Tailwind, and code Playground
HTML
<button data-toggle="offcanvas" data-alt-text="Close">Open</button>
JavaScript
jQuery.fn.toggleText = function() {
var altText = this.data("alt-text");
if (altText) {
this.data("alt-text", this.html());
this.html(altText);
}
};
$('[data-toggle="offcanvas"]').click(function () {
$(this).toggleText();
});