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

210
Vistas
How can I add a string to an array when a checkbox is checked?

These are my strings and their speeds at which they will be displayed

var typed = new Typed(".auto-input", {
        strings: ["Hi, blahblahblah.", "blahblahblah...", "...blahblahblah?"],
        typeSpeed: 75,
        backSpeed: 75,
        loop: true
    });

This is my code for when my checkbox is checked

var checkbox = document.getElementById('checkbox');

checkbox.addEventListener('change', () => {
  document.body.classList.toggle('dark');
});

I tried an if statement

if (document.body.classList.toggle('dark')) {
  typed.push(["lorem"]);
}

But then i realized, i think i need to select the "strings" in my "typed" vaiable. I'm not quite sure how to do that. I apologize in advance for any mistakes, this is my first question posted on StackOverflow.

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

0

As you want to push "lorem" into strings inside Typed, your if statement should look like:

if (document.body.classList.toggle('dark')) {
  typed.strings.push("lorem");
}
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