Bootstrap switch checked event?

前端 未结 9 1540
感情败类
感情败类 2021-01-31 14:48

I use this codes for checkbox checked event but it does not work.

css



        
相关标签:
9条回答
  • 2021-01-31 15:33

    This work for me.

    $(".switch").bootstrapSwitch({
            'size': 'mini',
            'onSwitchChange': function(event, state){
                console.log('switched...')
            },
            'AnotherName':'AnotherValue'
        });
    
    0 讨论(0)
  • 2021-01-31 15:40

    Note: The bootstrap docs now use the second example.

    For bootstrap-switch 3.0 release candidate the event previously given as an example on the official page was:

    $('#switch-change').on('switchChange', function (e, data) {}); 
    

    It doesn't get fired!

    Solution - use this instead :

    $('#switch-change').on('switchChange.bootstrapSwitch', function (event, state) {}); 
    

    where state parameter is the value of the checkbox.

    0 讨论(0)
  • 2021-01-31 15:42

    this worked for while using bootstrapSwitch

        $('body').on('switchChange.bootstrapSwitch','.switch',function () {
            alert('Done')
        });
    
    0 讨论(0)
提交回复
热议问题