Huyi-23
2/12/2016 - 3:50 PM

Responsive JS

Responsive JS

var tablet = matchMedia('screen and (min-width: 720px) and (max-width: 1023px)');

tablet.addListener(function (mql) {
  if (mql.matches) {
    $("body").removeClass("m").addClass("t");
  }
});

var mobile = matchMedia('screen and (max-width: 719px)');

mobile.addListener(function (mql) {
  if (mql.matches) {
    $("body").removeClass("t").addClass("m");
  }
});

if(escritorio.matches){
  $("body").removeClass("m").addClass("t");
} else if(tablet.matches){
  $("body").addClass("t");
} else if(mobile.matches){
  $("body").addClass("m");
}