1

I am using bootstrap switch for setting value to NO when its OFF and Yes when its ON,

in HTML,

<input type="checkbox" id="limit" class="make-switch" data-on="success" data-on-color="success" data-off-color="danger" data-size="small">

in JS

    $("#limit").bootstrapSwitch();
    $('#limit').on( 'switchChange',function () {
    if ($("#limit").bootstrapSwitch('state') === true)
    {
        console.log('On');
    }
    else {
        console.log('Off');
    }
});

When i change switch i could not get any output on log,

What is wrong? and how can we get value of input field with bootstrap switch?

Thanks,

rjcode
  • 1,193
  • 1
  • 25
  • 56

1 Answers1

3

Instead of switchChange use the following event :

$('#limit').on('switchChange.bootstrapSwitch',function (e,data) {
    //.......
});
Rambler
  • 4,994
  • 2
  • 20
  • 27