“Js一个一个显示文字”的版本间的差异

来自通约智库
跳转至: 导航搜索
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
 
http://www.tywiki.com/index.php/MediaWiki:Common.js
 
http://www.tywiki.com/index.php/MediaWiki:Common.js
  
 
+
<script>
 
这里是想要显示的文字,这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字
 
这里是想要显示的文字,这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字
 +
</script>
 
<!DOCTYPE html>
 
<!DOCTYPE html>
 
<html lang="en">
 
<html lang="en">

2019年12月7日 (六) 12:47的最新版本

http://www.tywiki.com/index.php/MediaWiki:Common.js

<script> 这里是想要显示的文字,这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字 </script> <!DOCTYPE html> <html lang="en">

<head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title>Document</title>

</head>

<body>

   <script>
       var pp = document.querySelector("p");
       var str = "这里是想要显示的文字,这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字这里是想要显示的文字"
       n = 0;
       var timer;
       timer = setInterval(function () {
           if (n < str.length) {
               pp.innerHTML += str.charAt(n);//sunstring(0,n)
               n++
           } else {
               clearInterval(timer);
           }
       }, 100)
   </script>

</body>

</html>

https://blog.csdn.net/datuzidppd5556/article/details/99638105