Jquery word for word fade in effect

前端 未结 1 1085
-上瘾入骨i
-上瘾入骨i 2021-01-07 06:39

ive been looking in about for this exact script for a while and i cant get it to work. Im looking to use a fade in effect from left to right word by word.

For examp

相关标签:
1条回答
  • 2021-01-07 06:41

    Here's a simple approach that you can build on. It creates the needed spans and fades them in based on interval value you set.

    var fadeInterval = 300
    
    $('h1').html(function(_, txt){
        var words= $.trim(txt).split(' ');
        return  '<span>' + words.join('</span> <span>') + '</span>';
    }).find('span').each(function(idx, elem){        
        $(elem).delay(idx * fadeInterval).fadeIn();
    });
    

    DEMO

    0 讨论(0)
提交回复
热议问题