Created
November 12, 2015 11:35
-
-
Save omariosouto/5cb7f7ef5190794a2bd5 to your computer and use it in GitHub Desktop.
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
(function (window, document, undefined) { | |
'use strict'; | |
// Initialize the media query | |
var mediaQuery = window.matchMedia('(min-width: 560px)'); | |
// Add a listen event | |
mediaQuery.addListener(doSomething); | |
// Function to do something with the media query | |
function doSomething(mediaQuery) { | |
if (mediaQuery.matches) { | |
document.body.style.backgroundColor = 'CornflowerBlue'; | |
} else { | |
document.body.style.backgroundColor = 'FireBrick'; | |
} | |
} | |
// On load | |
doSomething(mediaQuery); | |
// Modernizr | |
//window.addEventListener('resize', function() { | |
// if (Modernizr.mq('(min-width: 560px)')) { | |
// document.body.style.backgroundColor = 'CornflowerBlue'; | |
// } else { | |
// document.body.style.backgroundColor = 'FireBrick'; | |
// } | |
//}, false); | |
})(window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment