Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class="special-text js-target">
    target
  </div>
</body>
</html>
 
.special-text {
  font-size: 18px;
  background: red;
}
.special-text.is-matched {
  background: green;
}
 
const el = document.querySelector('.js-target');
const media = window.matchMedia('(min-width: 992px)');
const handleMediaChange = (event) => {
  if (event.matches) {
    el.classList.add('is-matched');
    el.innerText = ">= 992";
  } else {
    el.classList.remove('is-matched');
    el.innerText = "< 992";
  }
}
handleMediaChange(media);
media.addListener(handleMediaChange);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers