JSFiddle - React, Tailwind, and code Playground

HTML

<span id="content">
    
</span>

<input type="button" id="stop" value="stop"/>

JavaScript

var intervalID = window.setInterval(function() {
  var elem = document.getElementById('content');
  elem.innerText += 'a';
}, 500);


$("#stop").click(function(){
    window.clearInterval(intervalID);
});