Q:

reset jquery if 2 of 2 functions not executed within 5 seconds?

i am trying to add a timeout or reset to this piece of jquery.
<script type="text/javascript"> 
  var $msgNav = $('.nav4');
$msgNav.on('click', handler);

function handler() {
    $('.drop_down_column3').toggle();

    handler = function () { //overwrite handler
        window.location.href = "messages.php"; //
    }

    $msgNav.off('click').on('click', handler);
    return false;
}
</script>

basically what is happening here is i am essentially making a navigation menu. if the user clicks on the div 'nav4' the first time then a dropbox/drop_down_column3 displays. Then if the user clicks 'nav4' the second time they are taken to a url link.
What i want to do now is add a time out function or a reset function to this so that if the user does not carry out the second click within 5 seconds then the jquery starts over or resets itself as if the first click hasn't happened yet.
can someone please show me how i might do this?

A:

Like this?
var $msgNav = $('.nav4'), $dropDown = $('.drop_down_column3');

$msgNav.one('click', handler); //Register the handler just once

function handler() {
    $dropDown.toggle();

    $msgNav.one('click', function () {  //Set up second click event
        window.location.href = "messages.php"; 
    });

    window.setTimeout(function(){ //Wait for 5 seconds 
        $dropDown.toggle();// Add this if you want to toggle the div again
        $msgNav.off('click').one('click', handler); //turnoff the handler and reset to old
    }, 5000)
    return false;
}

Demo

