取消用户点击确认框'取消'

时间:2011-12-22 09:46:04

标签: javascript jquery confirm

这可能是一个非常简单的问题,但我找不到答案,所以希望有人可以提供帮助?

如果用户点击确认框中的“取消”,您如何取消点击操作?

到目前为止我有这个但是找不到我需要填写的空白。

jQuery('#doaction').click(function(e){
    if(jQuery('#bulk-action-selection').val() === 'delete'){
        var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
    }
    if(action === false){
        { Cancel the click and don't delete the items }
    }
});

3 个答案:

答案 0 :(得分:4)

 if( action === false )
    return false;

这应该有用。

答案 1 :(得分:3)

试试这个:

jQuery('#doaction').click(function(e){
    if(jQuery('#bulk-action-selection').val() === 'delete'){
        var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
        if(action === false) {
           return false; // this would do
        }
    }
});

答案 2 :(得分:2)

不要这样做:

jQuery('#doaction').click(function(e){
    if(jQuery('#bulk-action-selection').val() === 'delete'){
        var action = confirm('Are you sure you wish to delete the selected User Groups? This action cannot be undone.');
    }
    else {
        return false;
    }
});