首页 > 编程语言 > 详细

javascript queue 打字效果

时间:2015-10-20 15:13:42      阅读:262      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jquery queue</title>
    <script src="framework/jquery-1.10.2.min.js"></script>
    <script>
        var content = "javascript is a good language!!";
        $(function(){
            function callback(){
                console.log(this);
            }

            function notify(word){
                console.log("notify:" + word);
                $("#content").append(word);
            }

            var arr = content.split( );

            $.each(arr,function(index,item){
                for(var i=0; i<item.length; i++) {
                    // console.log(i + " !!i = " + (!!i) + (!i));
                    (function(word){
                        $("#content").queue("dynamicStyle", function(next){
                            callback.call($(this));
                            notify(word);
                            next();
                        }).delay(200,"dynamicStyle");
                    })(item[i]);
                }
                $("#content").queue("dynamicStyle", function(next){
                            callback.call($(this));
                            notify("&nbsp;");
                            next();
                }).delay(200,"dynamicStyle");
                
            });

            

            $("#content").dequeue("dynamicStyle");
        });
    </script>
</head>
<body>
    <div id="content"></div>
</body>
</html>

 

javascript queue 打字效果

原文:http://www.cnblogs.com/byxxw/p/4894764.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!