190
rated 0 times
[
197]
[
7]
/ answers: 1 / hits: 19417
/ 10 Years ago, wed, july 23, 2014, 12:00:00
I don't want to listen for the event of the switch being toggled, instead I want to use JavaScript to check it's current checked state.
<input type=checkbox name=pushtoggle state=true data-role=none>
I have this simple JavaScript to check the checked value:
if ($('#pushtoggle').is(':checked')){ alert('checked'); } else { alert('not checked');}
No matter which state (on or off) the switch is set to I always get the alert that it is not checked.
I initialized the toggle switch using:
$([name='pushtoggle']).bootstrapSwitch();
I also tried setting the checked attribute within the input tag. Nothing works to get me the correct state of the switch.
More From » jquery