كيف - تأثير الكتابة
تعرف على كيفية إنشاء تأثير كتابة باستخدام JavaScript.
خلق تأثير الكتابة
الخطوة 1) أضف HTML:
مثال
<p id="demo"></p>
الخطوة 2) أضف JavaScript:
مثال
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);
}
}
نصيحة: تعرف على المزيد حول طريقة window.setTimeout () في مرجع JavaScript الخاص بنا.