Home / JS / How TO – Media Queries with JavaScript – Write Media Queries with JavaScript Code

How TO – Media Queries with JavaScript – Write Media Queries with JavaScript Code


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

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

Hits: 4

Leave a Reply