¿Es posible modificar el siguiente código para que cuando haga clic en un botón con el ID #slide-1-next, se ejecute el código javascript? Idealmente, el código no se ejecutaría hasta que se haya hecho clic en el botón. No estoy muy versado en JS, pero creo que tal vez la última línea de código con el detector de eventos se puede modificar para lograr esto.
let text = 'What follows is Lorem ipsum translated to English: But I must explain to you how all this mistaken idea of reprobating pleasure and extolling pain arose.'; function type() { let textChar = text.charAt(textLength++); let paragraph = document.getElementById("typed"); let charElement = document.createTextNode(textChar); paragraph.appendChild(charElement); if(textLength < text.length+1) { setTimeout('type()', 50); } else { text = ''; } } document.addEventListener("DOMContentLoaded", function() { type(); });Para resumir los comentarios anteriores, agregar la siguiente línea al final de su bloque de código ejecutará la función de type cuando se haga clic en el botón con ID slide-1-next :
document.getElementById("slide-1-next").onclick = type;