2014-05-03 25 views
-1

jquery逐個淡出字母。它一下子全部消失。jquery逐個淡入字母之一

<script> 
    $(document).ready(function() { 
     $('#html1').hide().fadeIn(1000); 
    }); 
</script> 

我需要拆分字符串還是什麼?

+0

你能提供jsfiddle嗎? –

+0

看看這裏:http://stackoverflow.com/questions/18214066/fade-in-string-characters-with-jquery – Aaron

+2

這就是你要找的,http://jsfiddle.net/bGsa3/5/[第一個結果在GOOGLE中] –

回答

0
To get the individual letters to fade in, they need to be DOM elements. 

var string = $('#html1').html(); 
$('#html1').html(""); 
    var q = jQuery.map(string.split(''), function (letter) { 

    return $('<span>'+letter+'</span>'); 
    }); 

    var destination = $('#html1'); 

    var c = 0; 

    var i = setInterval(function() { 

    q[c].appendTo(destination).hide().fadeIn(1000); 
    c += 1; 

    if (c >= q.length) clearInterval(i); 
    }, 1000);