jquery动态输入

  • A+
所属分类:Web前端
<!DOCTYPE html> <html>     <head>         <meta charset="utf-8" />         <meta name="viewport" content="width=device-width, initial-scale=1">         <title></title>         <script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>         <script type="text/javascript">             $(document).ready(function() {                 var offset = 0;                 var jqSpan = $("span");                  inputEveryOne("暂不恢复旅行社及在线旅游企业出入境团队旅游及“机票+酒店”业务");                  function inputEveryOne(val) {                     var timer;                     var arr = [];                     arr = val.split("");                      timer = setInterval(function() {                         jqSpan.text(jqSpan.text() + arr[offset]);                          if (++offset >= arr.length) {                             clearInterval(timer);                             return;                         }                     }, 200);                 }             });         </script>     </head>     <body>         <h1>             官方:             <span></span>         </h1>     </body> </html>

jquery动态输入