JSFiddle - React, Tailwind, and code Playground

by lakshmipriya001

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();
    });