+ 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
4 Respuestas
+ 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
+ 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?
0
Raj Kalash Tiwari but i need the typing text effect
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