I'm having some trouble with the following Jquery code:
JQUERY
$(document).ready(function(){
$('#modalLogout').click(function(){
$('#yes').click(function(){
function time()
{
$(location).attr('href',"destroy.php");
}
/*set 1s after ckick in yes, after that redirect to index*/
setTimeout(function(){time()},1000);
/*table fadeout effect*/
$(".row").hide("slow");
});
});
});
What happens is that when opening a modal confirmation window if you are sure if you want to continue or end the session, when I click YES it does nothing the first time, I have to reopen the window and YES to the time () function to be executed. Already when I click on NO it works correctly, that is, it closes the window and remains in the session started. How could I change this strange behavior and improve the code?