const mquery = window.matchMedia( "(max-width: 768px)" );
if (mquery.matches) {
// window width is upto 768px
} else {
// window width is more than 768px
}
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”
Comments are closed.