zoukankan      html  css  js  c++  java
  • js实现字符串一个一个依次显示

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <body>

    一:
    <textarea id="showStr"></textarea>
    <div style="display:none" id="string">请在此输入您想咨询的问题
    </div>
    <script language="javascript">
    var index=0;
    var str=document.getElementById("string").innerHTML;
    function type(){
    if(index==str.length){index=0;}
        document.getElementById("showStr").innerText = str.substring(0,index++);
    }
    setInterval(type, 500);
    </script>

    二:

    <p id="aa" class="string"></p>
    <p style="display:none" id="w">请在此输入您想咨询的问题</p>

    <script type="text/javascript">
    window.onload = type;
    var index = 0;
    var word = $("#w").html();

    function type(){
    $("#aa").html(word.substring(0,index++));
    if(index > word.length) {
    return;
    } else {
    setTimeout(type,430);
    };
    }

    </script>


    </body>
    </html>

    原文链接:https://blog.csdn.net/liu__hua/article/details/38869615

  • 相关阅读:
    PHP的语言规范
    Js 中的this
    Js 事件
    Js DOM 操作
    Js DOM对象
    Js 对象三
    Js 定时器
    Js 对象二
    Js 对象
    POJ 2987 Firing(最大流最小割の最大权闭合图)
  • 原文地址:https://www.cnblogs.com/weibo806/p/8944892.html
Copyright © 2011-2022 走看看