I know about matchMedia.js but I was thinking I could detect the current @media rule with something as easy as this. However, it's not working in firefox – (which usually means it's not correct in the first place...) Looking at it now, shouldn't the content be on an :after pseudo element? Any advice? I have a CodePen HERE:
CSS
#test {
content: "small"
}
@media only screen and (min-width: $bp1) {
#test {
content: "medium"
}
}
jQuery
var sizeCheck = function() {
if ( $("#test").css('content') === 'small') {
$('.proof').text('jQuery knows this page is SMALL from reading the CSS @media rules.');
} else if ( $("#test").css('content') === 'medium') {
$('.proof').text('jQuery knows this page is MEDIUM from reading the CSS @media rules.');
}
};
// run the function on document ready
$(document).ready(sizeCheck);
// AND run the function on window resize event
$(window).resize(sizeCheck);