Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda