programming-examples/js/Basic/Rotate the string 'w3resource' in right direction by periodically removing one letter from the end of the string and attaching it to the front..js
2019-11-18 14:44:36 +01:00

12 lines
345 B
JavaScript

function animate_string(id)
{
var element = document.getElementById(id);
var textNode = element.childNodes[0]; // assuming no other children
var text = textNode.data;
setInterval(function ()
{
text = text[text.length - 1] + text.substring(0, text.length - 1);
textNode.data = text;
}, 100);
}