Created
July 21, 2023 07:44
-
-
Save yehchge/8da083be151355d25ded0f4b2888301b to your computer and use it in GitHub Desktop.
逐字顯示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script> | |
window.onload=function(){ | |
var story = document.getElementById('word'); | |
var s = document.getElementById('show'); | |
var i = 0; | |
timer=setInterval(function(){ | |
s.innerHTML=story.innerHTML.substring(0,i); | |
i++; | |
if(s.innerHTML==story.innerHTML){ | |
clearInterval(timer); | |
} | |
},200); | |
} | |
</script> | |
</head> | |
<body> | |
<p id="word" style="display:none;">從前有座山,山里有座廟,廟里的和尚講故事,講的啥故事;從前有座山。。。</p> | |
<p id="show"></p> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment