Breaking News
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: 11

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.