Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,026 questions

51,982 answers

573 users

How to move text animation in browser with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
  
<head>
<style type="text/css">

#div-id {
 position:absolute;
}

</style>
</head>
  
<body>

<script>

var divid = null; 

function move(count) 
{
    divid.style.left = parseInt(divid.style.left) + 1 + 'px';
    if (count > 200)
        return;  
    setTimeout(function() {move(count + 1);}, 10); // Recursive setTimeout call move every 10msec
}

function init() 
{
  divid = document.getElementById('div-id'); 
  divid.style.left = '0px'; 
  move(1); // start animating
}

window.onload = init;

/*
run:
 
Move the text "Hi" 200 pixels to the right
   
*/

</script>

<div id="div-id">Hi</div>

</body>
  
</html>

 



answered Jul 17, 2015 by avibootz
...