Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!