# Animating images with DHTML

**URL:** <https://forum.kirupa.com/t/animating-images-with-dhtml/222626>\
**Category:** Uncategorized\
**Created:** [April 15, 2007, 3:49pm UTC](https://forum.kirupa.com/t/animating-images-with-dhtml/222626 "2007-04-15T15:49:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![digitalmatt](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalmatt/32/694_2.png) [@digitalmatt](https://forum.kirupa.com/u/digitalmatt)\
**Post date:** [April 15, 2007, 3:49pm UTC](https://forum.kirupa.com/t/animating-images-with-dhtml/222626/1 "2007-04-15T15:49:45Z")

</div>

Hey, guys. What I’m trying to do is get the arrow to move to the position of the link and stop. Right now I only have it working for “Bottom”, but when I click on Bottom a second time the arrow keeps going. My guess is that my script is not getting the original position of the DIV in which arrow resides. Shouldn’t it not continue since I used the clearTimeout function? Here’s my code:

```auto
<script type="text/javascript">
    
    var i = 1
    function moveToBottom() {
    
        var position = document.getElementById('pointer').style.top =+ i + "px"
        counter = setTimeout("moveToBottom()",10)
        i++
        if (position == 200 + "px") {
        
            clearTimeout(counter)
        }
    }
    
</script>

```

and here’s the example: [http://www.digitalmatt.net/DHTML/week2/elevator1.html](http://www.digitalmatt.net/DHTML/week2/elevator1.html)
