Skip to content

Instantly share code, notes, and snippets.

@sudarshanReddykurri
Created September 11, 2016 07:44
Show Gist options
  • Save sudarshanReddykurri/aaf76de8965dc07db6fcf5cf9f758e14 to your computer and use it in GitHub Desktop.
Save sudarshanReddykurri/aaf76de8965dc07db6fcf5cf9f758e14 to your computer and use it in GitHub Desktop.
Targeting Media Queries in Javascript
function mediaqueryresponse(mql){
if (mql.matches){
alert("The condition " + mql.media + " has been met");
}
else{
alert("Condition not met yet");
}
}
var mql = window.matchMedia("screen and (max-width: 480px) and (orientation: portrait)");
mediaqueryresponse(mql) ;
mql.addListener(mediaqueryresponse);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment