I am trying to reproduce media query: max-width: 1024px with javascript and I just misunderstand the difference as I get different values with document.width and window.width
My question is which one is correct or a match, here is my code:
if($(document).width() < 1024){
console.log($(document).width());
return true;
} else {
return false;
}
In modernizr I would do it like that but I am trying not to use it.
if (Modernizr.mq('only all and (max-width: 1024px)')) {
return true;
} else {
return false;
}
Thank you.