Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <button class="toggleButton">Toggle panel</button>
  <div class="panel">Hi, I'm a toggleable panel</div>
  
</body>
</html>
.panel {
  margin-top: 1em;
  color: #fff;
  font-family: sans-serif;
  display: block;
  padding: 1em;
  background: red;
}
 
const toggleButton = document.querySelector('.toggleButton')  
const toggleablePanel = document.querySelector('.panel');  
const buttonInitialState = false;
const clicks = Rx.Observable.fromEvent(toggleButton, 'click');
const determinePanelVisibility = () => {  
  return toggleablePanel.style.display === 'none'
}
const toggle = clicks  
                .map(determinePanelVisibility)
toggle.subscribe ((show) => {  
  toggleablePanel.style.display = show ? 'block' : 'none';
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers