JavaScript – Event listener with window.matchMedia not triggering

I’ve panned through countless solutions to this problem and none of them have fixed my issue. I very simply have a navigation bar, which, when on a mobile browser, disappears and becomes replaced with a button, whose function is to show and hide the navigation bar. Now, I want my listener to, when the window is shrunk, show the button and hide the navigation bar. When the window is expanded, the button should be hidden and the navigation bar should be shown. The button is working as it should be, since the media query doesn’t affect it. My listener appears

CSS media queries and JavaScript window width do not match

For a responsive template, I have a media query in my CSS: @media screen and (max-width: 960px) { body{ /* something */ background:red; } } And, I made a jQuery function on resize to log width: …