Alexancho Posted March 31, 2013 Share Posted March 31, 2013 I use a js function that moves a background image and i want to stop this moving after a time.I tried to use setTimeout() and clearTimeout() methods, but it doesn't stop the movement.What is the problem? <script type="text/javascript" language="javascript"> function MoveBg(){some code} $(function() { var i = setTimeout("MoveBg()" ,200);setTimeout(function(){clearTimeout(i)},10000); }); </script> Link to comment Share on other sites More sharing options...
justsomeguy Posted April 1, 2013 Share Posted April 1, 2013 MoveBg probably has its own call to setTimeout. That would be the interval ID that you need to clear. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now