Skip to content

Instantly share code, notes, and snippets.

@zesda
Last active December 17, 2015 12:49
Show Gist options
  • Save zesda/5612517 to your computer and use it in GitHub Desktop.
Save zesda/5612517 to your computer and use it in GitHub Desktop.
Dynamically fetches the media query stylesheet breakpoints from the DOM. Currently no support for multiple media ranges, i.e. media = "screen and (min-width:X) and (max-width:Y)"
var arr = new Array();
$('link[media]').each(function(i){
typeof($(this).attr('media').split('(')[1]) !== 'undefined'
? arr.push(new Array($(this).attr('media').split('(')[1].split(':')[0], $(this).attr('media').split('(')[1].split(':')[1].split('px')[0]))
: null ;
});
console.log(arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment