var windowWidth = window.matchMedia("(max-width: 992px)") // custom $(document).ready(function () { function windowWidthChange(windowWidth) { if (windowWidth.matches) { // If media query matches console.log("Jeg er under 992px") } else { console.log("Jeg er over 992px") } } windowWidthChange(windowWidth) windowWidth.addListener(windowWidthChange)