Jquery sweetAlert-单击确认按钮时不调用函数
我通过以下方式添加了以下警报,但当我单击“取消”或“确认”按钮时,没有调用任何函数,我是否做错了什么?我的母版页有指向css的链接:Jquery sweetAlert-单击确认按钮时不调用函数,jquery,css,asp.net,Jquery,Css,Asp.net,我通过以下方式添加了以下警报,但当我单击“取消”或“确认”按钮时,没有调用任何函数,我是否做错了什么?我的母版页有指向css的链接: sweetAlert({ html: true, title: 'Error', text: "test", type: 'warning', showCancelButton: t
sweetAlert({
html: true,
title: 'Error',
text: "test",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Check',
}).then((result) => {
if (result.value) {
sweetAlert("Yes", "Blah", "info");
} else {
sweetAlert("No", "Blah", "info");
}
});
如果您使用的是
jQuery
,请在要调用操作的DOM元素上附加click事件,并弹出SweetAlert
弹出窗口。使用SweetAlert
或SweetAlert
实例触发(fire
)事件
以下示例将帮助您从以下内容开始:
$(函数(){
常量事件={
单击:“单击”
};
const$button=$('somethingToDo');
$button.on(events.click,函数(event){
常量配置={
是的,
标题:“错误”,
文本:“测试”,
键入:“警告”,
showCancelButton:true,
confirmButtonText:“检查”,
};
//第一变体
sweetAlert.fire(配置)。然后(回调);
函数回调(结果){
if(result.value){
//第二种变体
SweetAlert.fire(“是”、“废话”、“信息”);
}否则{
//第二种变体
SweetAlert.fire(“否”、“废话”、“信息”);
}
}
});
})
做点什么
Sweet alert还需要包含其.js文件