gpt4 book ai didi

javascript - 当在 typed.js 上键入特定字符串时,有没有办法触发动画或类更改

转载 作者:行者123 更新时间:2023-11-27 23:47:45 26 4
gpt4 key购买 nike

我想在使用 typed.js 键入特定字符串时触发字符串的出现,我想知道是否可以使用 typed.js 执行此操作,或者我是否应该使用替代方法。

我尝试过根据按钮的出现来计时打字,但我想要一种更可靠的方法。

function typingSentences() {
var typed = new Typed('#typed', {
stringsElement: '#typed-strings',
typeSpeed: 50,
cursorChar: '|',
backSpeed: 10,
});
}
 <div class="appearingText">   
<a class="aboutClass">About</a>

</div>
.appearingText {
text-align: center;
margin-top: 2.3em;
font-size: 1.6em;
}

.aboutClass {
margin-left: -35em;
color: white;
background-color: #9561ac;
border-radius: .35em;
padding: .4em;
font-family: 'Comfortaa', cursive;
font-size: .7em;
}

最佳答案

您可以使用 onStringTyped() 回调方法捕获 Typed.js 键入的内容。这是一个例子:

var typed = new Typed('#typed', {
stringsElement: '#typed-strings',
typeSpeed: 50,
cursorChar: '|',
backSpeed: 10,
onStringTyped: function(pos, self) {
if (self.currentElContent === 'String to look for') {
// Do your string appearance manipulation here
} else {
// Reset your string appearance if needed here
}
});

关于javascript - 当在 typed.js 上键入特定字符串时,有没有办法触发动画或类更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56692776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com