這篇文章主要介紹了JavaScript實(shí)現(xiàn)打字效果的方法,可實(shí)現(xiàn)文字陸續(xù)出現(xiàn)的打字效果,涉及javascript時(shí)間函數(shù)及頁(yè)面元素獲取的相關(guān)技巧,需要的朋友可以參考下
本文實(shí)例講述了JavaScript實(shí)現(xiàn)打字效果的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
- <input type="button" onclick='start("高考了")' value="start"/>
- <input type="text" id="here" />
- <script type="text/javascript">
- function start(str1)
- {
- str=str1;
- len=str.length;
- i=0;
- dwrite();
- }
- function dwrite()
- {
- document.getElementById('here').value=document.getElementById('here').value + str.charAt(i);
- if( i++ ==len )
- {
- i=0;
- return true;
- }
- setTimeout('dwrite()',500);
- }
- </script>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選