If you don't have to support IE9 you can just use window.matchMedia()
(MDN documentation).
function checkPosition() {
if (window.matchMedia('(max-width: 767px)').matches) {
//...
} else {
//...
}
}
window.matchMedia
is fully consistent with the CSS media queries and the browser support is quite good: http://caniuse.com/#feat=matchmedia
UPDATE:
If you…
Top comments (0)