Jquery animation repeating code
I have made code but I want it to be execute repeatedly till the user is on the page.
Here is my code---
$(document).ready(
function animate() {
$('div.lightining').stop().animate({
backgroundColor: '#789'
}, 1050, 'linear', function() { });
}
function () { $('div.lightining').cycle(animate()); }
);
I want that the script to repeat itself after getting completed. Does someone get any ideas of achieving this. Please开发者_开发技巧 help me out!
Thanks in advance!
$(document).ready( function() {
function animate() {
$('div.lightining').stop().animate({
backgroundColor: '#789'
}, 1050, 'linear', function() { animate(); });
}
animate();
});
the code below will loop an animation continuously where
attribute is the attribute to animate
value the value to animate to
and duration the duration.
set these to whatever you want.
once the animation is complete the callback calls the animation again.
$(document).ready(function(){
animate();
});
function animate(){
$(".lightning").animate({
attribute:value
},duration,function(){
animate();
});
}
not sure what you mean about the on the page part. you will have to clarify there. also if im correct, you cant animate background colour without a plugin.
精彩评论