I was going through this tutorial http://www.schillmania.com/content/projects/javascript-animation-1/ and when I institute the code, I get my div to move 10px to the right, but only once, what if I wanted to keep clicking the button and have it move an additional 10px every time, or if the setTimeout() was instituted shouldnt it keep calling that function and adding an additional 10px ever 20ms? I know it's probably an easy solution, so if anyone could help it would be greatly appreciated. (I'm just learning so no insults).
<div onclick="invis('one')" id="one"></div>
<button onclick="domove()">hello</button>
<div onclick="invis('two')"id="two"></div>
<div onclick="invis('three')"id="three"></div>
<script type="text/javascript">
function domove()
{
$("one").style.left+=10+'px';
setTimeout(domove,20);
}
</script>
I have the #one{} css stylings as follows:
width: 100px;
height: 50px;
float: left;
margin-right: 10px;
background-color: blue;
position: relative;