Alex Rivera | Logout

jQuery delete confirmation box

Asked 2012-04-25T05:48:20.197
40

In my jQuery am displaying my results in a table formatted output, a part of my jQuery is

<td class='close' onclick='deleteItem(#ITEMID,#ITEMNAME)'></td>

here "close" is a CSS class and in this class I have cross mark image, if I click this cross mark the function(deleteItem) will be fired.

here what I want to do is if I click this cross mark a "delete confirmation box" should pop up and if I click yes this onclick event should fire, else if I click No nothing should happen.

How can I achieve this, can anyone help me....

Edit
Report

1 Answer

121

You need to add confirm() to your deleteItem();

function deleteItem() {
    if (confirm("Are you sure?")) {
        // your deletion code
    }
    return false;
}
answered 2012-04-25T05:51:25.867

Your Answer