[init] initial commit
This commit is contained in:
36
js/typeWriter.js
Normal file
36
js/typeWriter.js
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
let i = 0;
|
||||
let text1 = "你好啊,小扈同学,很高兴认识你!";
|
||||
let text2 = "愿我们每一天都是值得纪念的,也是值得怀念的。"
|
||||
let speed = 100;
|
||||
|
||||
function typeWriter(text, para){
|
||||
if(ok == 2){
|
||||
clearInterval(typeInterval);
|
||||
}
|
||||
if(i < text.length){
|
||||
document.getElementById(para).innerHTML += text.charAt(i);
|
||||
i++;
|
||||
speed = Math.random() * 50 + 100;
|
||||
}
|
||||
else{
|
||||
if(ok == 0){
|
||||
i = 0;
|
||||
}
|
||||
ok += 1;
|
||||
}
|
||||
}
|
||||
|
||||
var typeInterval;
|
||||
|
||||
//window.onload = function() {
|
||||
// window.onload = function(){};
|
||||
typeInterval = setInterval(function(){
|
||||
if(ok == 0){
|
||||
typeWriter(text1, "txt1");
|
||||
}
|
||||
else if(ok == 1){
|
||||
typeWriter(text2, "txt2");
|
||||
}
|
||||
}, 300);
|
||||
//};
|
||||
Reference in New Issue
Block a user