minhur / bootstrap-toggle

Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles
http://www.bootstraptoggle.com
MIT License
1.48k stars 440 forks source link

Value is always true #225

Closed danielh-official closed 3 years ago

danielh-official commented 3 years ago
$('#example').change(function () {
    console.log(document.getElementById('example').value);
});

With this code, if I click on a checkbox initialized with this toggle,

<input type="checkbox" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="danger" id="example" data-size="large">

it will always yield "true" in the browser's console, regardless of whether it's "Yes" or "No".


Nevermind. I should change the code to this:

$('#example').change(function () {
    console.log(document.getElementById('example').checked);
});