javascript - jQuery CSS Opacity Animate -
so i'm trying create simple fading slideshow 5 slides repeats when finished.
i feel i've got should work, it's not.
<script type="text/javascript"> $(document).ready(function() { function playslide(){ settimeout(function(){ $("#slide-two").animate({"opacity":"1"}, 2000, 'swing').delay(11000).animate({"opacity":"0"}, 1, 'swing')}, 10000); settimeout(function(){ $("#slide-three").animate({"opacity":"1"}, 2000, 'swing').delay(11000).animate({"opacity":"0"}, 1, 'swing')}, 20000); settimeout(function(){ $("#slide-four").animate({"opacity":"1"}, 2000, 'swing').delay(11000).animate({"opacity":"0"}, 1, 'swing')}, 30000); settimeout(function(){ $("#slide-five").animate({"opacity":"1"}, 2000, 'swing').delay(11000).animate({"opacity":"0"}, 2000, 'swing')}, 40000); } playslide(); }); </script>
the idea first slide have opacity set 1, when last slide fades out, it's if it's starting again. each slide hold 10 seconds before fading out , after each slide fades in, previous slide's opacity set 0 ready next time repeats.
i hope it's not obvious mistake. apologies if is...
please why not use .fadein()
, .fadeout()
instead?
settimeout(function () { $("#slide-two").fadein(400, function () { settimeout(function () { $("#slide-two").fadeout(function () { $("#slide-three").fadein(400, function () { // on... }); }, 1000); }); }, 1000);
better use these functions doing instead of manually animating opacity.
Comments
Post a Comment