Bootbox没有显示弹出模式

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

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文件

    

您使用了错误的选择器。 您使用标记而不是类来进行“切换”。 你需要使用

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

代替。

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

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