Issue: Typed JS code is not finishing before next function is called.
Solution: Add anything to make it wait before executing the next function.
I know there are solutions already posted to this kind of problem but I can't get any of them to work. This is a last resort.
<html>
<body>
<button onclick="myFunction()">Button</button>
<div>
<p id="coolArray" onload="myFunction"></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
function myFunction() {
var typed = new Typed("#coolArray", {
strings: ["pHolder1", "pHolder2", "pHolder3", "pHolder4", "pHolder5", "pHolder6", "pHolder7", "pHolder8"],
typeSpeed: 70,
backSpeed: 70,
loop: false,
showCursor: false,
smartBackspace: false
});
}
function newFunction() {
for (i = 1; i < 50; i++) {
// do smth else
}
}
</script>
</body>
</html>
Edit: I made it fully functioning from copy, sorry for inconvenience.
I needed the
oncomplete
attribute. took a little digging but I found out how to use it. This was my first time using TypedJS and I didn't know about this attribute, and I still don't know many others, but I hope to get better. Thanks for your help!