Jquery word for word fade in effect

前端 未结 1 1087
-上瘾入骨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  '' + words.join(' ') + '';
    }).find('span').each(function(idx, elem){        
        $(elem).delay(idx * fadeInterval).fadeIn();
    });
    

    DEMO

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题