Html marquee change text

2.1k views Asked by At

I have a information text area and it is represented in marquee right to left. But I also update text every 45 second and i want to restart the motion of marquee

How can i restart the moving of text when the text changed? I use angular js controller for update the text in every 45 seconds

1

There are 1 answers

0
Axiom On

You could simply just use javascript to remove the <marquee> tags and put another <marquee> tag with new text every time.

<div id="my_text" ></div>
<script>
var text = ["<marquee>Hello</marquee>", "<marquee>I like tacos</marquee>"];
var counter = 0;
setInterval(change, 45000);
function change() {
    document.getElementById("my_text").innerHTML = text[counter];
    counter++;
    if(counter >= text.length) { counter = 0; }
}
</script>