+ 1

How can I use the text printed in the tag <p>? without using a variable

Please see the code below How can I use the text printed in the tag <p>? without using a variable "a" // Output should be same Thank you! https://code.sololearn.com/Wqgn0d5Z92lx/?ref=app

14th Apr 2020, 12:09 AM
PR PRGR
PR PRGR - avatar
4 Antworten
+ 2
You can just remove var a and use that statement directly where uou want to print , as it is html it is quite easy
14th Apr 2020, 12:21 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 1
I think this is what he is saying. <p id="gg">need TO TYPE this</p> <script> var b=0; var c=setInterval(()=>{ document.getElementById("gg").textContent += " hi i am laith"[b]; if(b==13){ clearInterval(c); } else { b++; } },100) </script> PR PRGR is this what you need?
14th Apr 2020, 1:43 AM
ChaoticDawg
ChaoticDawg - avatar
0
Raj Kalash Tiwari but i need the typing text effect
14th Apr 2020, 1:21 AM
PR PRGR
PR PRGR - avatar
0
<script> var x = 0; let a="hi i am laith"; let p = document.getElementById("gg"); const arr = a.split(""); var c = function(){ if(x == arr.length){ clearInterval(c); } else{ p.innerHTML += arr[x]; x++; } }; setInterval(c,1000); may be try this.. this one is much more responsive
14th Apr 2020, 2:23 AM
Ayan Poddar
Ayan Poddar - avatar