Created
December 23, 2016 23:09
-
-
Save marcus-at-localhost/1ebd5556698ea6d08adccbac4ee13e50 to your computer and use it in GitHub Desktop.
Use media queries in javascript
From http://stackoverflow.com/questions/19261761/difference-between-matchmedia-and-enquire-js?rq=1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matchMedia("screen and (min-width:40em)").addListener(function(mql) { | |
if(mql.matches) { | |
// do something when matching | |
} | |
else { | |
// do soemthing when no match | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment