文字逐个出现效果

文字一个个出现的demo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<pre id="showWord"></pre>
<div style="display:none" id="word">
   xxxxxxxxxxxxxxxxxxxxx
</div>
<script language="javascript">
    var index=0;
    var word=document.getElementById("word").innerHTML;
    function type(){
        document.getElementById("showWord").innerText = word.substring(0,index++);
    }
    setInterval(type, 200);
</script>
</body>
</html>

 

posted @ 2017-04-17 11:08  莫问、前程  阅读(845)  评论(0编辑  收藏  举报