कैसे करें - टाइपिंग प्रभाव
जावास्क्रिप्ट के साथ टाइपिंग प्रभाव बनाने का तरीका जानें।
एक टाइपिंग प्रभाव बनाना
चरण 1) HTML जोड़ें:
उदाहरण
<p id="demo"></p>
चरण 2) जावास्क्रिप्ट जोड़ें:
उदाहरण
var i = 0;
var txt = 'Lorem ipsum typing effect!'; /* The text */
var
speed = 50; /* The speed/duration of the effect in milliseconds */
function
typeWriter() {
if (i < txt.length) {
document.getElementById("demo").innerHTML += txt.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
युक्ति: हमारे JavaScript संदर्भ में window.setTimeout() पद्धति के बारे में अधिक जानें ।