Thats what i have so far i want to set a timeout for function spid()
<script type="text/javascript">
$(document).ready(function() {
$("#spid").animate({top: '-110px' }, 600, 'easeOutBounce',
function spid() {
$(this).animate({top:"-=20px"},1000).animate({top:"+=20px"},1000);
setTimeout("spid()",2000);
});
});
views:
29answers:
2
A:
You just need to pass in a function.
setTimeout( spid,2000 );
Or you could also just use setInterval
.
BBonifield
2010-09-20 16:26:55
A:
$(function() {
$("#spid").animate({top: '190px' }, 600,'linear' ,function() {
(function spid() {
console.log('Test');
$(this).animate({top:"+=20px"},1000).animate({top:"+=20px"},1000);
setTimeout(spid,2000);
})();
});
});
There is a problem with this
in the above code, below code snippet works fine
Edit :
$(function() {
$("#spid").animate({top: '110px' }, 600,'linear' ,function() {
var cache = $(this);
(function spid() {
cache.animate({top:"+=20px"},1000).animate({top:"-=20px"},1000);
setTimeout(spid,2000);
})();
});
});
please Test the code http://jsbin.com/elaxa3
Ninja Dude
2010-09-20 16:59:10
it shows test,test,test
Noob
2010-09-20 17:06:52
yep, which means that the code works fine. isn't it =)
Ninja Dude
2010-09-20 17:14:24
yes it works but it dosent animate
Noob
2010-09-20 17:15:48
this part of the code dosent work $(this).animate({top:"+=20px"},1000).animate({top:"+=20px"},1000);
Noob
2010-09-20 17:16:47
nvm its not working when i put "#spid" instaed of "this" its works otherwise it dosent work
Noob
2010-09-20 17:30:26
thanks it works
Noob
2010-09-20 18:08:09
you're welcome noob, sorry I don't know your name =)
Ninja Dude
2010-09-20 18:11:57