how to stop interval for animation with its own speed in jquery?
<p>I am trying to figure out how to do this... I have a function that moves a div, this function has a speed property (500 ms), and its used for animate and move the div.. so, what I basically trying to do is everytime I am over a button call that function ,the problem is that I cant stop the interval after I leave the mouse (I am using <code>mouseenter</code> and <code>mouseleave</code>) and I want to call that function delaying 500ms to call it (I tried with <code>myfunction().delay(500);</code> ) but its the same result...</p>

<p>Any idea how to do this? and how to stop my interval on mouseleave?</p>

<p>(for mouseleave I am using <code>clearInterval(myinterval);</code> ) but no result</p>

<pre><code>jQuery('#next-div').mouseenter(function() {
    setInterval(function() {
        var interval = images.moving; //this function has an spped of animation of 400 each transaction
    }, 400); 
}).mouseleave(function(){
    clearInterval(interval);
}); 
</code></pre>
