你好我不知道我的标题是否有帮助,但这里是我的问题我想在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'或''
–