我正在使用typed.js插件来实现打字效果。我有两行,在第一行结束后,我想从第二行开始。这是我尝试过的,问题是,当它切换到第二行时,您可以简单地看到
正在键入标记。我不想这样。请告诉我我哪里做错了。我也试着在first的回调中调用类型化函数,但没有起作用:(
下面是我的代码
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="typed.js"></script>
<title>Typed.js</title>
<style>
.test {
font-size: 30px;
}
</style>
</head>
<body>
<span class="box1"></span>
<span class="box2"></span>
<script>
$(function(){
$(".box1").typed({
strings: ["First sentence.", "<p></p><span class='test'>Second sentence.</span>",""],
typeSpeed: 0,
showCursor: false,
});
});
</script>
</body>
</html>请告诉我我哪里做错了
发布于 2020-08-05 07:47:25
可能太晚了,但是我意识到你可以用white-space: pre;向你想要显示的字符串中添加一个\n,并设置类型元素的样式,它不需要显示任何标签就可以工作。
所以Javascript代码应该是这样的:
$(function(){
$(".box1").typed({
strings: ["First sentence.", "\n<span class='test'>Second sentence.</span>",""],
typeSpeed: 0,
showCursor: false,
});
});而CSS将是:
.box {
white-space: pre;
}它也只适用于一个字符串。
发布于 2014-12-11 21:26:31
您是否尝试添加contentType属性?
$(".box1").typed({
strings: ["First sentence.", "<p></p><span class='test'>Second sentence.</span>",""],
typeSpeed: 0,
showCursor: false,
contentType: 'html'
});https://stackoverflow.com/questions/27422711
复制相似问题