Confirm Box Before Delete Item using jquery – onlinecode
In this post we will give you information about Confirm Box Before Delete Item using jquery – onlinecode. Hear we will give you detail about Confirm Box Before Delete Item using jquery – onlinecode And how to use it also give you demo for it if it is necessary.
When we will click on delete recorded, after then will open the confirm box and will ask you, are you sure delete this record. that time this tutorial help you.
Here, we have simple create “users” table and then list all users with table using bootstrap. Using bootstrap it looks better layout. So added delete button, when user will click on delete button confirm box open and ask to remove or not current item. after click on yes fire ajax and remove the current record.
This is a way of ensuring that items are not accidentally deleted, or the wrong item deleted by mistake. When clicked on the link, then open the confirmation box. if the user selects ‘ok’ then delete is done. if the user selects on ‘no’ or ‘cancel’ then not delete records..
See below example
// first example for Confirm Box Before Delete Item using jquery <a href="delete.php?delete_id=<?php echo $row['id'];?>" onclick="return confirm('Are you sure you want to delete this item?');">Delete</a> // second example for Confirm Box Before Delete Item using jquery <a href="delete.php?delete_id=<?php echo $row['id'];?>" data-confirm="Are you sure to delete this item?">Delete</a> $('.delete').on("click", function (e) { e.preventDefault(); var choice = confirm($(this).attr('data-confirm')); if (choice) { window.location.href = $(this).attr('href'); } });