Home » Javascript » setInterval for animation string of text javascript [on hold]

setInterval for animation string of text javascript [on hold]

Posted by: admin August 19, 2018 Leave a comment

Questions:

I thought I was making repetative running text from the input inside the text box, but it does not do it.

<div>
  <input type="text" id="textInput">
  <button id="btnAnime" onclick="moving()">animate</button>
</div>

<div id="animOutput"></div>

<script>
  var runText = document.getElementById('textInput');
  var divAnim = document.getElementById('animOutput');
  var counter = 0;

  function scrls() {
    var scrolText = runText.value;
    divAnim.innerHTML = scrolText.slice(counter);
    counter++;
    setInterval(scrls, 100);
  }

  function moving() {
    setInterval(scrls, 100);
  }
</script>
Answers: