+ 2
Why not printing word by word ??? (TextAnimation) [Solved]
27 Respostas
+ 5
There's some nice code linked here by people. Thanks Sofi (DM Closed❌) and others.
I wrote an ES6 style solution which uses setInterval() to get the typing effect and clearInterval() for cleaning up, without needing any recursion.
https://code.sololearn.com/WebK43H2QT7l/?ref=app
+ 3
Abhishek Singh
because setInterval works till until there is no clear interval after certain time period.
+ 3
Abhishek Singh it will help you
https://code.sololearn.com/Wqj6Q89m1ux6/?ref=app
+ 3
var i = 0, text;//i = 0, for starting with first letter
text = "Hello️" //writing text
function typing() {
if (i < text.length) { // if i less than text letters do something
var a = document.getElementById("text")//getting text on htmk for writing in it
a.innerHTML += text.charAt(i); // in htmk write text i-rd letter CharAt return only one letter
i++;//i += i
setTimeout(typing, 70); //for animation
}
}
onload=typing;
+ 2
Abhishek Singh
That's not a right way to convert in array. You can use split function to convert string in array
https://code.sololearn.com/W398ljZC8DTN/?ref=app
Stop setInterval like this
https://code.sololearn.com/Ws124zm38Cm9/?ref=app
+ 2
Abhishek Singh you want typing animation?
+ 2
You can use css for it also😁
+ 2
Sofi (DM Closed❌) thank you very much
But can anyone explain me this code 🤔😔😕😪
I don't want to just copy it
+ 2
Sofi (DM Closed❌) thank you very much
+ 2
Abhishek Singh do you really understand?
+ 2
You can refer this Abhishek Singh
https://code.sololearn.com/WUfKwT785jx0/?ref=app
+ 2
Krish [less active] thank you very much
+ 2
Sofi (DM Closed❌) yes I understood it sis
+ 1
Abhishek Singh
What you want to do ?
+ 1
Abhishek Singh
Word by word will not print because it's a string. If you want to print word by word then convert in array.
+ 1
🅰🅹 thank you I mean to print it like this
https://code.sololearn.com/WkGxaoTWrBHe/?ref=app
by other means 😇😇
+ 1
Sofi (DM Closed❌) yes you are right
+ 1
Sofi (DM Closed❌) trying something new 😅😆😅
+ 1
CamelBeatsSnake thanks for helping me
+ 1
I know you already got solution
But try with extra delay & line break features in short code
https://code.sololearn.com/W1pzn70v4SGc/?ref=app