lamperic
3/12/2020 - 9:42 AM

media query

js

// media query
if (matchMedia) {
  const mq = window.matchMedia("(max-width: 767px)");
  mq.addListener(WidthChange);
  WidthChange(mq);
}
function WidthChange(mq) {
  if (mq.matches) {
  // SP code
  } else {
  // PC code
  }
}