JSFiddle - React, Tailwind, and code Playground

HTML

<!--Just have an element with id=loadingDots-->
<span style="font-size:42px">Sending<span id="loadingDots"></span></span>

JavaScript

$(document).ready(function(){ 
    //call the function in document.ready somewhere    
    showLoadingDots();
});


var showLoadingDots = function() {
    var showDots = setInterval(function(){   
    //look for the element with id=loadingDots
    //if not found clear the interval
    if ($("#loadingDots").length>0) {
        var dots = '...',i=1;
if ($("#loadingDots").html().length==0 || ($("#loadingDots").html().length == dots.length)){
            $("#loadingDots").html('');
            var i = 1;
        } else {
            i++;
        }        
        $("#loadingDots").html($("#loadingDots").html()+".");
        } else {
           //clear the interval, if element not found
           clearInterval(showDots);
        }         
    },400); 
}