我的问题是,即使我单击Cancel
确认中的按钮,链接仍会导航到其目的地?cancel
如果用户在确认框中单击,我如何阻止链接导航到目的地?我只希望它在用户单击OK
按钮时导航:
<a id='teachlogout' href='./teacherlogout.php'>Logout</a>
function logoutHandler() {
if (confirm("You are currently creating an Assessment, are you sure you want to logout?" + "\n" + "(Your current assessment details will be lost)" + "\n")) {
return true;
}
}
// logout link
$('#teachlogout').click(function() {
logoutHandler();
});