Created
November 19, 2013 22:50
-
-
Save steverydz/7554013 to your computer and use it in GitHub Desktop.
Responsive JavaScript
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 checkWidth() { | |
var viewportWidth = window.innerWidth; | |
// If the viewport width is greater than 640px | |
if (viewportWidth > 640) { | |
// Execute your code | |
} else { | |
// Do something else | |
} | |
} | |
(function () { | |
// Calls checkWidth function when page has loaded | |
checkWidth(); | |
// Calls checkWidth function when window has been resized | |
window.onresize = checkWidth; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment