There is no need to disable default startup. Just do the following:
$(function() {
$(".del").click(function(evt) {
if (!confirm("Are you sure you want to delete this?")) {
evt.preventDefault();
}
});
});
It is easier and more logical to prevent an event if you need to, rather than prevent it, and then prevent it (if possible).
Remember that the code will stop working when a confirmation window is displayed to the user until the user selects OK or Cancel.
, JavaScript: event.preventDefault() vs return false. , , stopPropagation(), return false:
$(function() {
$(".del").click(function(evt) {
if (!confirm("Are you sure you want to delete this?")) {
return false;
}
});
});