Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
  <ul class='navbar-items'>
    <li>1zzzz</li>
    <li>2zzzz</li>
    <li>3zzzz</li>
    <li>4zzzz</li>
  </ul>
  <div class="overlay">qwerty</div>
</body>
</html>
 
.navbar-items {
  list-style:none;
}
.navbar-items li {
  display:inline-block;
  margin-right:10px;
  border:1px solid black;
  padding:5px;
  cursor:pointer;
}
.navbar-items li.active {
  color:red;
  border-color:red;
}
.overlay {
  position:fixed; 
  top:100px;
  left:0;
  right:0;
  bottom:0; 
  background:#ddd;
  opacity:0;
}
.overlay.active {
  position:fixed; 
  top:100px;
  left:0;
  right:0;
  bottom:0; 
  background:#ddd;
  opacity:1;
}
 
$(function() {
  var li = $(".navbar-items li");
  li.on("click", function() {
    if (!$(this).is(".active")) {
      li.removeClass("active");
      $(this).addClass("active");
      $(".overlay").addClass("active");
    } else {
      $(".overlay").removeClass("active");
      $(this).removeClass("active");
    }
  });
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers