我绝对是JavaScript的初学者。所以我需要你的帮助。当用户单击“提交”按钮时,我需要弹出一条成功消息。我试图制作一个JavaScript来解决该任务,但是由于它什么都不做,所以shuold出错了。
按钮(HTML):
<button name="submit" type="submit" class="btn btn-primary btn-xl" id="sendMessageButton" action="form.js">Küldés</button>
JavaScript文件:
$("#sendMessageButton").click(function(){
Swal.fire(
'Good job!',
'You clicked the button!',
'success'
);
});
答案 0 :(得分:0)
您需要在HTML顶部添加对sweetAlert的引用:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
然后一切正常。
答案 1 :(得分:0)
您加载了sweetalert CDN吗? 如果是的话,那就去做。。
$("#sendMessageButton").click(function(){
swal({
title: "Good Job",
text: "You clicked the button!.",
type: "success"
},
function () {
//thing which you want to do on click the button of alert
//location.reload();
});
});