如何在脚本中添加确认是或否

How to add confirmation yes or no in script

本文关键字:确认 添加 脚本      更新时间:2023-09-26

如何在提交前添加是/否确认?我希望在继续删除或编辑之前收到提醒消息。如何做到这一点?

jQuery(function ($) {
        $('a.button.edit, a.button.remove').click(function () {
            if ($('input[name="checkbox[]"]:checked').length == 0) {
                return;
            }
            var frm = document.myform;
                if($(this).hasClass('edit')){
                frm.action = 'editpr.php';
            }
                if($(this).hasClass('remove')){
            }
            frm.submit();
        })
    })

使用window.confrm()显示确认对话框。

jQuery(function ($) {
    $('a.button.edit, a.button.remove').click(function () {
        if ($('input[name="checkbox[]"]:checked').length == 0) {
            return;
        }
        if(!confirm('do you want to contine')){
            return
        }
        var frm = document.myform;
        if ($(this).hasClass('edit')) {
            frm.action = 'editpr.php';
        }
        if ($(this).hasClass('remove')) {}
        frm.submit();
    })
})