gpt4 book ai didi

javascript - 甜蜜警报语法

转载 作者:行者123 更新时间:2023-11-28 18:59:05 24 4
gpt4 key购买 nike

我未能获得甜蜜的警报,我认为这与语法有关。有人可以告诉我我应该做什么

<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<script src="dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="dist/sweetalert.css">
</head>
<body>
<script>
swal({
title: 'Confirm',
text: 'Are you sure to delete this message?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, sir',
cancelButtonText: 'Not at all'
});
</script>
</body>
</html>

最佳答案

在 html 中添加一个按钮并触发 onclick 事件。

例如使用标准查询选择器

document.querySelector('button#test-1').onclick = function(){
swal({
title: 'Confirm',
text: 'Are you sure to delete this message?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, sir',
cancelButtonText: 'Not at all'
});
};
<link href="http://t4t5.github.io/sweetalert/dist/sweetalert.css" rel="stylesheet"/>
<script src="http://t4t5.github.io/sweetalert/dist/sweetalert.min.js"></script>
<button id="test-1">Show alert</button>

关于javascript - 甜蜜警报语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986381/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com