Skip to content

Instantly share code, notes, and snippets.

@YamilG
Created September 5, 2014 05:23
Show Gist options
  • Save YamilG/dc8b2ff5ba5f757ba536 to your computer and use it in GitHub Desktop.
Save YamilG/dc8b2ff5ba5f757ba536 to your computer and use it in GitHub Desktop.
Check if mobile
var sw = document.body.clientWidth,
sh = document.body.clientHeight,
breakpoint = 650,
mobile = true;
$(document).ready(function() {
checkMobile();
});
$(w).resize(function(){
sw = document.body.clientWidth;
sh = document.body.clientHeight;
checkMobile();
});
function checkMobile() {
mobile = (sw > breakpoint) ? false : true;
if (!mobile) {
// if not mobile
} else {
// or else...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment