I'm currently using a setInterval
function so that I can repeat text with an extra letter added to it for every 5 secs, hence I've set the time period for the setInterval
function as 5000.
But I also want this function to be executed as soon as the page loads. To be clear the logic present inside the setInterval
function should be executed as soon as the page loads and it should also be repeated for every 5 secs. Is it possible with setInterval
function or else is there any other way to do it? Thank you in advance :)
setInterval(function(){
var x = document.getElementById('sample');
x.innerHTML = x.innerHTML+'L';
},5000);
<p id="sample">Sample Text</p>