Add and remove class with jQuery media queries.

example on how add and remove div class with jQuery media queries.

on window resize

$(window).resize(function(){

if ($(window).width() <= 767) {  
$("#masthead").removeClass("uk-position-center");
}  

if ($(window).width() >= 768) {  
$("#masthead").addClass("uk-position-center");
}    

on document ready

$(document).ready(function(){

if ($(window).width() <= 767) {  
$("#masthead").removeClass("uk-position-center");
}  
   
if ($(window).width() >= 768) {  
$("#masthead").addClass("uk-position-center");
}        
});

Leave a Reply

avatar
  Subscribe  
Notify of