I am using jQuery's .remove() to get rid of divs of content, but I would like to be able to have a confirmation or dialog box appear before it is removed. I am just not sure of the context of how I would write such a dialog.
$(".remove").click(function () {
$('div').remove('#item1');
});
Upon clicking the link with class remove I would like a box to popup saying Are you sure you want to remove this? Then click Yes to remove and no to keep it. Thanks in Advance
$(".remove").click(function () {
if(confirm("Are you sure you want to remove this?")) {
$('div').remove('#item1');
}
});
Try this:
$(".remove").click(function () {
if(confirm("are you sure you want to remove the div")){
$('div').remove('#item1');
}
});
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With