Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
Javascript incluyó la palabra indefinido como parte de la salida
 var i = 0; var txt = 'Christmas Family Service - Sunday 19th December at 11:45 am. Come along to Bethany Evangelical Church and find out about the real meaning of Christmas.'; /* The text */ var speed = 50; /* The speed/duration of the effect in milliseconds */ function typeWriter() { if (i < txt.length) { document.getElementById("demo").innerHTML += txt.charAt(i); i++; setTimeout(typeWriter, speed); } } <div class="announce"> <p id="demo"> <script> document.write(typeWriter()); </script> </p> </div>

C undefined servicio familiar navideño - domingo 19 de diciembre a las 11:45 am. Ven a la Iglesia Evangélica Betania y conoce el verdadero significado de la Navidad.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Su

 <p id="demo"> <script> document.write(typeWriter()); </script> </p>

inserta el valor de retorno de llamar a typeWriter en ese elemento #demo , pero la función no devuelve nada.

No hay una buena razón real para usar document.write de todos modos. Todo lo que necesita hacer es llamar a la función, no usar document.write también.

 var i = 0; var txt = 'Christmas Family Service - Sunday 19th December at 11:45 am. Come along to Bethany Evangelical Church and find out about the real meaning of Christmas.'; /* The text */ var speed = 50; /* The speed/duration of the effect in milliseconds */ function typeWriter() { if (i < txt.length) { document.getElementById("demo").innerHTML += txt.charAt(i); i++; setTimeout(typeWriter, speed); } } typeWriter();
 <div class="announce"> <p id="demo"></p> </div>

Arreglando otras partes del código:

  • Solo necesita seleccionar el elemento una vez, no cada vez que se ejecuta el ciclo
  • .innerHTML solo debe usarse cuando se inserta deliberadamente marcado HTML; con texto sin formato, .textContent es más rápido, más seguro y más predecible

 let i = 0; const txt = 'Christmas Family Service - Sunday 19th December at 11:45 am. Come along to Bethany Evangelical Church and find out about the real meaning of Christmas.'; /* The text */ const speed = 50; /* The speed/duration of the effect in milliseconds */ const demo = document.getElementById("demo"); function typeWriter() { if (i < txt.length) { demo.textContent += txt[i]; i++; setTimeout(typeWriter, speed); } } typeWriter();
 <div class="announce"> <p id="demo"></p> </div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda