Javascript typing effect

前端 未结 6 1366
刺人心
刺人心 2020-12-31 23:28

The issue arises from the same issue as last time. My websites run off a static domain, so I want to be able to use this script on each site without making duplicate copies.

6条回答
  •  爱一瞬间的悲伤
    2020-12-31 23:54

    If you want to define what text it prints out, you should pass the text through an argument, if I understand your question correctly.

    Try and mess with this:

    var type = function( elem , text , index )
    {
        var index = index||0;
        elem.innerHTML += text.charAt(index);
        index++;
    
        var t = setTimeout(function(){
            type( elem , text , index );
        },100);
    }
    type( document.getElementById('screen') , 'How\'re You?' );

    Hello,

提交回复
热议问题