JSFiddle - React, Tailwind, and code Playground

HTML

<button>0</button>

JavaScript

$('button').on('click',function(){
	if(x<5) x++; 
	else x = 0;
  
  this.innerHTML = x
})


var x = 0