How to add media query using javascript.

Add sufficient HTML code in your HTML file.

How to add media query using javascript.expoundsofttechsolution How to add media query using javascript.
<div class="Container">
<h1>What is Lorem Ipsum?</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting  and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

Add the following javascript code to your js file.

<script>
var x = window.matchMedia("(max-width: 767px)")
estsFunction(x) // Call listener function at run time
x.addListener(estsFunction) // Attach listener function on state changes

function estsFunction(x) {
  if (x.matches) { // If media query matches
    document.body.style.backgroundColor = "red";
  } else {
   document.body.style.backgroundColor = "blue";
  }
}

</script>