Skip to content Skip to sidebar Skip to footer

Text To Text How I Fix It

I put text in

tags and the script is supposed to cycle through the

s, fading out the old text and fading in the new. My problem is that all the

s are sh

Solution 1:

Your code works and doesn't reproduce the mentioned effect/error, but it's not efficient, you can cache the objects and use .eq() method, you can also use the .fadeOut()'s callback function that is executed when animation is complete.

var $p = $('#container p'), i = 0;

$p.not(':first').hide();

setInterval(function () {
    $p.filter(':visible').fadeOut(function(){
        $p.eq( ++i % $p.length ).fadeIn();
    });
}, 2000);

http://jsfiddle.net/dAvcV/

Post a Comment for "Text To Text How I Fix It"