<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <p id="p1">啊啊啊啊啊啊啊啊啊啊啊啊啊</p> </body> <script> var p1 = document.getElementById("p1"); var p2 = p1.innerText.split(''); p1.innerText=''; var i=0; var qText = setInterval(function () { if (i<p2.length){ p1.innerText +=p2[i]; i++; }else { clearInterval(qText); } },100); </script> </html>
2.百度
5行代码带你实现一个js的打字效果
标签:输出,p1,打字,js,innerText,啊啊啊,var From: https://www.cnblogs.com/xmyfsj/p/17646657.html