Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
        <div id="one">ONE</div>
        <div id="two">TWO</div>
        <div id="three">THREE</div>
        <select>
            <option>one
            <option>two
            <option>three
        </select>
  
  <script>
    function show(id) {
      document.getElementById(id).style.display = '';
    }
    function hide(id) {
      document.getElementById(id).style.display = 'none';
    }
    function whichDiv(event) {
      var select = event.target;
      var options = select.options;
      for (var i = 0; i < options.length; i++) {
        var option = options[i];
        if (option.selected) {
          show(option.value);
        } else {
          hide(option.value);
        }
      }
    }
    
    document.querySelector('select').addEventListener('change', whichDiv);
  </script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers