<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> </div> </nav> <div class="col-md-6 well"> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-6"> <form> <div class="form-group"> <input name="text" class="form-control" id="text" value="" disabled /> </div> </form> </div> </div> </body> </html>
initialize(); function initialize(){ speed = 180 chars = 1 var timer; var text = "The quick brown fox jumps over the lazy dog. "; document.getElementById('text').value = text; } function animateText(btn) { timer = window.setTimeout('animateText()',speed); var msg = document.getElementById('text').value; document.getElementById('text').value = msg.substring(chars) + msg.substring(0,chars); btn.setAttribute("disabled", "disabled"); document.getElementById('stop').removeAttribute("disabled"); } function stopAnim(btn){ clearTimeout(timer); btn.setAttribute("disabled", "disabled"); document.getElementById('play').removeAttribute("disabled"); }