Show A Confirm Message Before Delete Data In JavaScript

In this quick example, I am gonna show you how to show a confirm alert before deleting data in javascript. I will use return confirm onclick concept to do this. Simply I will use a button to delete data. But when a user clicks on this button, we will show to him a confirmation alert before deleting this data.

I will simply share this delete confirmation message in javascript source code with you. If you are searching this show alert before delete data in javascript then this example is for you. I will use javascript confirm to do this.

Example code:

 $(document).on('click','.delete_button',function(event){
    if(!confirm("Do you want to really delete this?")) {
       return false;
    }

    //delete code goes here
});

 

Hope it can help you.

 

#javascript #jquery