Skip to content

Instantly share code, notes, and snippets.

@thedaviddias
Forked from usaphp/javascriptmediaqueries
Created July 8, 2014 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thedaviddias/4296dd0cfa732465c8be to your computer and use it in GitHub Desktop.
Save thedaviddias/4296dd0cfa732465c8be to your computer and use it in GitHub Desktop.
// HTML:
<div class="display-type"></div>
// CSS:
// set the content of an element depending on the media query
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) {
.display-type {
content: "tablet";
}
}
@media (max-width: @screen-xs-max) {
.display-type {
content: "phone";
}
}
// JAVASCRIPT
if($('.display-type').css('content') == "tablet"){
// Actions for tablets
}
if($('.display-type').css('content') == "phone"){
// Actions for smartphones
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment