So I want to create a tag
that the text moving from left to right with javascript. But sometimes it took longer to move the text And when I refreshed the page, it didn't run at the time I expected
My css code
#bao{
margin:0 auto;
width:600px;
min-height:100px;
}
#bao p{
text-align:center;
}
My html code
<div id="bao">
<p id="a">
Chúc mừng sinh nhật
</p>
</div>
My javascript code
abc();
function abc(){
var a = document.getElementById('a').innerHTML;
var c =a;
var b = c.slice(c.length-1,c.length)+ c.slice(0,c.length-1);
document.getElementById('a').innerHTML=b;
setTimeout(abc,200);
}
So What I expected is the text will keep running with the time delay is 200 millisecond but sometimes it took longer to run
will sometimes be delayed longer than 200millisecond. And What I want is to keep running with the delay is 200 millisecond
– yukinon Aug 17 '19 at 16:53