$(window).width(); not work at correct position
<p>Thats my code:</p>

<pre><code>$(window).on("load scroll resize", function() 
{
    if( $( window ).width() &gt;= 767)
    { 
        $( ".boxlogo" ).css("display","block");
        $( ".nav &gt; li").css("margin-top","95px");`

        var s = $(window).scrollTop();
        if(s  &gt; 1)
        {
            $( ".boxlogo" ).css("width","140px");
            $( ".navbar-color" ).css("background-color","#fff");
            $( ".dropdown-menu &gt; li &gt; a") .css("color","#000");
            $( ".dropdown &gt; a ").css("color","#000");
            $( ".nav &gt; li &gt; a").css("color","#000");                    
            $( ".dropdown-menu &gt; li &gt; a") .css("text-shadow","2px 2px #fff");
            $( ".dropdown &gt; a ").css("text-shadow","1px 1px #fff");
            $( ".nav &gt; li &gt; a").css("text-shadow","1px 1px #fff");
            $( ".nav &gt; li").css("margin-top","62px");
            $( ".dropdown-menu").css("background-color","#fff");
        }
        else 
        {
            $( ".boxlogo" ).css("width","200px");
            $( ".navbar-color" ).css("background-color","transparent");                
            $( ".dropdown-menu &gt; li &gt; a") .css("color","#fff");
            $( ".dropdown &gt; a ").css("color","#fff");
            $( ".nav &gt; li &gt; a").css("color","#fff");
            $( ".dropdown-menu &gt; li &gt; a") .css("text-shadow","1px 1px #000");
            $( ".dropdown &gt; a ").css("text-shadow","1px 1px #000");
            $( ".nav &gt; li &gt; a").css("text-shadow","1px 1px #000");
            $( ".dropdown-menu").css("background-color","transparent");
            $( ".nav &gt; li").css("margin-top","96px");
        }
    }//if windows
    else {
        $( ".boxlogo" ).css("display","none");
        $( ".nav &gt; li").css("margin-top","5px");
    }
});//scroll resize*/`
</code></pre>

<p>The problem is that: </p>

<pre><code>$( ".boxlogo" ).css("display","block");
$( ".nav &gt; li").css("margin-top","95px");
</code></pre>

<p>not work when the windows width is 767px but at 784px...why?? thats more important because is the point when menu change style.
I have try to use if( $( window ).innerWidth() >= 767) but the problem persist.
I also try to do that with css @media but not work at all.
I'm using bootstrap.</p>