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

156
Vistas
How to manipulate a toggle switch with DOM html

I have designed a toggle button using Pug, and I am running function1 whenever it is clicked. But what I want to do is that when the page is loaded I am getting a value from the backend that I want to use to set the initial state of the toggle button. Is there a way to use DOM manipulation to change the toggle button below? or some other way to do it from client-side Javascript?

p Hours Button
  label.switch#toggleButton
  input(type='checkbox' onchange='function1(this)')
  span.slider.round 

I am thinking maybe something like document.getElementById("toggleButton").attr(checked) or something like that. Any help would be really appreciated.

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

0

Pass a value of true or false in the property state, eg { state: true } if using Express.

p Hours Button
  label.switch#toggleButton
  input(type="checkbox" onchange="function1(this)" checked=state)
  span.slider.round
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