<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.9"></script>
</head>
<body>
<div class="element"></div>
<script type="text/javascript">
window.onload = function () {
var typed = new Typed(".element", {
strings: ['These are the default values...', 'You know what you should do?', 'Use your own!', 'Have a great day!'],
stringsElement: null,
typeSpeed: 100,
startDelay: 0,
backSpeed: 100,
smartBackspace: true,
shuffle: false,
backDelay: 700,
fadeOut: false,
fadeOutClass: 'typed-fade-out',
fadeOutDelay: 500,
loop: false,
loopCount: Infinity,
showCursor: true,
cursorChar: '|',
autoInsertCss: true,
attr: null,
bindInputFocusEvents: false,
contentType: 'html',
onComplete: (self) => {
console.log('所有打字都已完成调用的回调函数', self);
},
preStringTyped: (arrayPos, self) => {
console.log('在键入每个字符串之前调用的回调函数', arrayPos, self);
},
onStringTyped: (arrayPos, self) => {
console.log('输入每个字符串后调用的回调函数', arrayPos, self);
},
onLastStringBackspaced: (self) => {
console.log('在循环期间,在键入最后一个字符串之后调用的回调函数', self);
},
onTypingPaused: (arrayPos, self) => {
console.log('打字已经停止调用的回调函数', arrayPos, self);
},
onTypingResumed: (arrayPos, self) => {
console.log('停止后开始键入调用的回调函数', arrayPos, self);
},
onReset: (self) => {
console.log('重置后调用的回调函数', self);
},
onStop: (arrayPos, self) => {
console.log('停止后调用的回调函数', arrayPos, self);
},
onStart: (arrayPos, self) => {
console.log('开始后调用的回调函数', arrayPos, self);
},
onDestroy: (self) => {
console.log('销毁后调用的回调函数', self);
}
});
}
</script>
</body>
</html>