Created
April 14, 2014 10:30
-
-
Save sugarshin/10635973 to your computer and use it in GitHub Desktop.
window.matchMedia
This file contains 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
var MM = window.matchMedia("(max-width: 400px)"), | |
docbody = document.body; | |
function doMediaCheck () { | |
if (MM.matches) { | |
docbody.innerHTML = 'less than 400'; | |
docbody.className = 'orange'; | |
} else { | |
docbody.innerHTML = 'more than 400'; | |
docbody.className = ''; | |
} | |
} | |
window.onresize = function () { | |
doMediaCheck(); | |
}; | |
doMediaCheck(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment