HTML,JavaScript打印机实现 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body style="background: #34495e;font-size: 28px;color: white;text-align: center;"> <script src="https://cdnjs.cloudflare.com/ajax/libs/TypewriterJS/1.0.0/typewriter.min.js"></script> <div id="asklz"></div><!--打印机--> <script> var dyj = document.getElementById('asklz'); var typewriter = new Typewriter(asklz, { loop: true }); typewriter.typeString("如果我爱你,绝不像攀援的凌霄花,借你的高枝炫耀自己;") .pauseFor(2500)//打印机的速度 .deleteAll()//删除上一句 .typeString('如果我爱你,绝不学痴情的鸟儿,为绿荫重复单调的歌曲;') .pauseFor(2500) .deleteAll() .typeString('也不止像泉源,常年送来清凉的慰藉;') .pauseFor(2500) //.stop()停止 .deleteAll() .typeString('也不止像险峰,增加你的高度,衬托你的威仪。') .pauseFor(2500) .deleteAll() .typeString('甚至日光,甚至春雨。《致橡树》--舒婷') .pauseFor(2500) .deleteAll() .start(); </script> <div></div> </body> </html>