JSFiddle - React, Tailwind, and code Playground

by nate

HTML

<button>Click Me</button>

<p id="log"></p>

JavaScript

var $log = $('#log');

$('button').on('click', function (event) {
    var $this = $(this);
    var current = $this.data('current') || 0;
    
    current += 1;
    
    // Output the current item
    $log.text(current);
    
    // Save the new current value to the button
    $this.data('current', current);
});