How to determine switch state in javascript?


Topic: How to determine switch state in javascript?

david1 pro asked 7 years ago

Given the example switch:

<div class="switch">
    <label>
      Off
      <input type="checkbox">
      <span class="lever"></span>
      On
    </label>
  </div>
 How can the state of the switch (on/off) be determined via javascript? I would like to use this state to dictate behavior of other javascript functions on the page.

david1 pro answered 7 years ago

Well typos suck... I was leaving out the ":"
$('#mycheckbox').is(':checked')
 

fjch1997 pro answered 7 years ago

How to do this using Knockout?

Bartłomiej Malanowski staff pro premium commented 7 years ago

Currently, we don't support Knockout

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No