我不明白为什么我的按钮无法与 SweetAlert2 通信

问题描述 投票:0回答:1

我有一份向员工发放装备和设备的表格。在底部,我有一个按钮,应该使用 SweetAlert2 弹出协议消息。我已经在 head 部分有了脚本和 css 链接。只是当我点击按钮时,什么也没有发生。我对此很陌生,并假设我错过了一些重要的事情。

<div class="mt-2">
<button  type="submit" class="btn btn-primary me-2" id="issueGear">Issue Gear</button>
<button type="reset" class="btn btn-outline-secondary">Cancel</button>
</div>

                        
<script type="text/javascript">

$(document).ready(function() {
$('#issueGear').click(function(){
Swal.fire({
type: 'success',
title: 'Agreement',
text: 'I agree to return all issued items upon my voluntary or involuntary dismissal from 
the department. If I fail to return any item(s), I may be help responsible for the 
replacement cost of the item(s).'
})
})
}
                 
</script>
javascript web-applications sweetalert2
1个回答
0
投票

“$(document).ready”中有语法错误

    <script type="text/javascript">
            $(document).ready(function() {
                $('#issueGear').click(function(){
                    Swal.fire({
                        type: 'success',
                        title: 'Agreement',
                        text: 'I agree to return all issued items upon my voluntary or involuntary dismissal from the department. If I fail to return any item(s), I may be held responsible for the replacement cost of the item(s).'
                    });
                });
            });
        </script>

然后将按钮类型更改为“按钮”

<button  type="button" class="btn btn-primary me-2" id="issueGear">Issue Gear</button>
© www.soinside.com 2019 - 2024. All rights reserved.