const mquery = window.matchMedia( "(max-width: 768px)" );

if (mquery.matches) {
// window width is upto 768px
} else {
// window width is more than 768px
}

4 thoughts on “How TO – Media Queries with JavaScript – Write Media Queries with JavaScript Code

  1. Pingback: Diyala Science1

Comments are closed.