I’m making a website with a typewriter function and I wanted to make multiple on the same page. I’m using the typewriter function from W3 schools. Can anyone help? The example website is difficult-rift-skateboard
the last part is where the two fight:
window.onload = typeWriter;
window.onload = typeWriter2;
window.onload
can only have one function set to it, the second one kicks out the first. so when the page loads, it’ll only run typeWriter2. you could set it to a function that runs both though:
function startTypeWriters() {
typeWriter();
typeWriter2();
}
window.onload = startTypeWriters;
or you can use a different event dispatcher interface to add both functions as handlers to the load event:
window.addEventListener('load', typeWriter);
window.addEventListener('load', typeWriter2);
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.