我有一份向员工发放装备和设备的表格。在底部,我有一个按钮,应该使用 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>
“$(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>