Idan Shechter Idan Shechter - 1 year ago 1101
Javascript Question

Changing a Switchery checkbox state from code

How do I programatically change a jQuery Switchery checkbox state from checked to unchecked (and vice versa)?

I tried using

global_switch_sound.prop('checked', true)
on the checkbox element but it doesn't work.


<input id="sound-active-input" type="checkbox" />


global_switch_sound = new Switchery(document.querySelector('#sound-active-input'));

Answer Source

Try this:


It should trigger a click and switch. OR this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download