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.

 

author-image
Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js