I'm using the bootstrap framework and I have a problem with my navigation.

Basically my nav has two different ways of the navigation working. The 'desktop' way and the 'mobile' way.

On the 'desktop' version when the user clicks on a nav link the submenu will appear over the entire screen. This is working correctly as it should.

The 'mobile' version is your standard mobile nav I suppose, only my jQuery looks for any parents then adds a + button next to it. When the user clicks the '+' the children will toggle down and show. This is working correctly too.

The problem comes when I try to resize the window and get them both working if the user was for some reason to switch from the 'desktop' to 'mobile' nav (I suppose checking out the responsiveness).

This is my jQuery:

```
$(".subnav").hide();

    $('.nav-collapse li').each(function(){
        var hasKids = $(this).find('ul').length > 0;
        if(hasKids){
            $(this).children('a')
            .append('<button>+</button>');                     
        }
    });

    function whatnav() {
        if ($(window).width() < 767) {
            $('.nav-collapse li').on('click', 'button', function(e){
                e.preventDefault();
                var plusOrMinus = $.trim($(this).text());

                if(plusOrMinus == '+'){
                    $(this).text('-');
                } else {
                    $(this).text('+');
                }

                $(this).parents('li').find('.subnav').toggle(250);
            });             
        } else {
            $("nav a").click(function () {
                $(this).parent('li').find(".subnav").css("display","table").fadeIn(250);
                event.stopPropagation();
            });
            $(".subnav").click(function() {
                $(this).fadeOut(250);
            });         

        }
    }

    $(document).ready(whatnav);
    $(window).resize(whatnav);

```

I created the function 'whatnav' and then made an IF statment - if the window is below 767px then use the 'mobile' nav otherwise use the 'desktop' nav jquery.

If I start in 'mobile' mode and then move to desktop it all works correctly. However if I then change back to the 'mobile' window width it still uses the 'desktop' jQuery snippet rather than the mobile one.

I've never used IF statements before - am I doing it wrong? Any help is appreciated!