Bootbox not 未显示弹出模式

Bootbox not is not showing pop up modal

我已经在我的项目中下载了 bootbox.js 并实现了此代码以显示弹出模式对话框,但是我的 console.I 中没有打印任何错误或成功结果,我对错误的产生位置感到困惑.

js文件

$('switch input[type="checkbox"]').on('change',function(){

        var checkbox=$(this);
        var checked=checkbox.prop('checked');
        var dMsg=(checked)? 'You want to activate the product':
                             'You want to deactivate the product';
        var value=checkbox.prop('value');

        bootbox.confirm({
            size: 'medium',
            title: 'Product Activation & Deactivation',
            message: dMsg,
            callback: function(confirmed){

                if(confirmed){
                    console.log(value);
                    bootbox.alert({
                        size: 'medium',
                        title: 'Information',
                        message : 'you are going to perform operation on product'+ value

                    });
                }
                else{
                    checkbox.prop('checked',!checked);
                }
            }

        });

    });

html 文件

 <!-- toggle switch -->
        <label class="switch">
            <input type="checkbox" checked="checked" value="4" />
            <div class="slider"></div>
        </label>

您使用了错误的选择器。对于 'switch',您使用了标签而不是 class。 您需要使用

$('.switch input[type="checkbox"]')

相反。

参考。 https://api.jquery.com/category/selectors/

此外,请确保您已添加依赖项 - jquery 和 bootstrap。 工作版本 - http://jsfiddle.net/grrakesh4769/85etyhfc/3/