I need to add a resize function so I can check and then apply classes on window resize. I can't use media-query so I have to achieve using javascript.
var mq = window.matchMedia( "(min-width: 640px)" );
var el = document.getElementById('output');
if (mq.matches) {
el.innerHTML ='640 and over';
el.className += 'over'
} else {
el.innerHTML ='640 and under';
el.className += 'under'
}
#output{
padding:20px;
color:#fff;
}
.over{
background:#808;
}
.under{
background:#f00;
}
<div id="output"></div>