JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div id="state">On</div>
<form action = "#">
<button id="btn">Toggle!</button>
<button>Don't Toggle</button>
<div>Total Button Clicks: <span id="total">0</span></div>
</form>
</body>
CoffeeScript
nextState = off
totalClicks = 0
$ ->
#Count how many button clicks there have been
$('form').submit ->
totalClicks++
$('#total').text totalClicks
false
#Toggle when the toggle button is clicked
$('#btn').click ->
$('#state').text if nextState then "On" else "Off"
nextState = !nextState