This time I will bring you JS to print text verbatim. What are the precautions for printing text verbatim with JS? Here is a practical case, let’s take a look.
The example in this article describes how to achieve simple text printing effect word by word using JavaScript. Share it with everyone for your reference, the details are as follows:
Let’s take a look at the running effect first:
##The specific code is as follows:<!DOCTYPE> <html> <head> <title> js打字效果</title> <meta charset="utf-8"> </head> <style type="text/css"> p { width:980px; margin:10px auto; background:#F3E6EA; border:2px outset #f9c6aa; color:green; } </style> <script type="text/javascript"> var i=1; function write() { var id=document.getElementById("main"); var msg="JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可JS打字机效果 ,原理很简单:每次多获取一个待打出的字符串的值,输出,覆盖原来输出的内容即可"; var len=msg.length; var msg1=msg.substring(0,i); id.innerHTML=msg1; if(i==len){clearInterval(t)} else i++; } function time1() { var t=setInterval(function(){write()},50); } </script> <body onload=time1()> <p id="main"></p> </body> </html>
Detailed explanation on the use of vuex status management
The above is the detailed content of JS makes text print verbatim. For more information, please follow other related articles on the PHP Chinese website!