I had some trouble with logout button, so i use confirm(); with on click event on jQuery. I use if statement for confirm that the user is click Ok or Cancle
Button script :
<a id="logout-btn">
<p>Logout</p>
</a>
Script that working :
$("#logout-btn").on("click", function() {
var acc = confirm("Are you sure want Logout?");
if (acc == true) {
window.location.href = "logout.php";
}else{
}
});
Script that isn't working :
$("#logout-btn").on("click", function() {
var acc = confirm("Are you sure want Logout?");
if (acc == true) {
window.location.href = "../logout.php";
} else {
}
});
The different between script just different folder but the second script when i click Cancel it still logout, What is the problem??