I have many links in a HTML-table, which delete corresponding row, when clicked (calling a PHP-script via GET parameter).
They all have a class delete_row
Very simple and effective one line solution without using jquery:
<a href="to/your/path" onclick="return confirm('Are you sure you want to delete?');">Delete</a>
you can use preventDefault method of the event object in the handler function:
jQuery('.delete_row').click(function(event){
if(!confirm('Really Delete?')){
event.preventDefault();
}
})
I think there is a error!
Use this:
$('.delete_row').click(function(){
return confirm("Are you sure you want to delete?");
});
Try this.
$('.delete_row').click(function(){
return confirm("Are you sure you want to delete?");
})
You could also call another function after confirm like this:
<a href="to/your/path" onclick="return confirm('Are you sure you want to delete?') && yourOtherFunction();">Delete</a>