JSFiddle - React, Tailwind, and code Playground

by psycketom

HTML

<a id="click-button">clickata</a>

JavaScript

$(function() {
    $('#click-button').on({
        firstClick : function()
        {
            // do something
            alert(111);
            
            // switch back
            $(this).data('nextClick', 'secondClick');
        },
        
        secondClick : function()
        {
            // do something
            alert(222);
            
            // switch back
            $(this).data('nextClick', 'firstClick');
        },
    
        click : function()
        {
            var nextClick = $(this).data('nextClick') || 'firstClick';
            $(this).trigger( nextClick );
        }
    });
});