< Back to Coding, jQuery

Using JS to mimic media queries

Sometimes this is required. To do this use:

var winSize = window.outerWidth;
if(winSize === undefined){
            winSize = $(window).width();
        }
        console.log(winSize);
        if (winSize > 480) {
            // change style for non-mobile
        } else {
           // change style for mobile
        }

View the demo

Download the demo

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *