Q:

How do I add a 3 seconds delay to this function?

This is a function for a toggle navigation and it stays open when page is loading. Can anyone help on how to add a delay to this function?
$(document).ready(function () {
    $('body').addClass('js');
    var $menu = $('#menu'),
        $menulink = $('.menu-link');
    $menulink.click(function () {
        $menulink.toggleClass('active');
        $menu.toggleClass('active');
        return false;
    });
});

A:

Look into setTimeout. e.g. setTimeout(myFunction, 3000) will call myFunction in 3 seconds.
        $(document).ready(function() {
                $('body').addClass('js');
                var $menu = $('#menu'),
                    $menulink = $('.menu-link');
                $menulink.click(function() {
                    $menulink.toggleClass('active');
                    $menu.toggleClass('active');

                    // If I'm understanding the question correctly, 
                    // you want the menu to go away after 3 seconds
                    setTimeout(function() {
                        $menulink.toggleClass('active', false);
                        $menu.toggleClass('active', false);
                    }, 3000);
                    return false;
                });
        });

