你好我不知道我的標題是否有幫助,但這裏是我的問題我想在JS,CSS,HTML中做一個類型編寫器效果,除了當我嘗試添加一條不顯示的新行時,添加一行新文本。如何在腳本中添加新行
\t var str = "<p>I want to put text here then another line under this one</p>",
\t <!--var str = "<p>text here</p>",--> <!--This is what I tried to do to add a new line-->
i = 0,
isTag,
text;
(function type() {
text = str.slice(0, ++i);
if (text === str) return;
document.getElementById('typewriter').innerHTML = text;
var char = text.slice(-1);
if(char === '<') isTag = true;
if(char === '>') isTag = false;
if (isTag) return type();
setTimeout(type, 80);
}());
#typewriter {
\t \t color: lime;
\t \t text-align: center;
\t }
<div id="typewriter"></div>
你可以用'\ N'或''
–