mercredi 28 janvier 2015

Check page width then apply css in jquery

I am trying to get jQuery to check the window width on resize. If the window is greater than 960px I'd like to apply display: block; inline style to the class .main-navigation. This is what I have so far but I can't get the syntax right.



jQuery(window).resize(function($) {
if ($(window).width() < 960) {
document.getElementByClass(".main-navigation").style.display = 'block';
}
else {}
});

Aucun commentaire:

Enregistrer un commentaire