You need to use the return value:
<a onclick="return askCar();" ... >
Just having it inside the onclick
will execute the function but to actually cancel the click, you need to use the return value.
Also, the code can be slightly optimized:
function askCar(){
return confirm ("Are you sure for deleting car ?");
}
No need in if..else
when you can directly return the dialog result. (unless of course you want to perform exra actions)