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>
  
  <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
  
  <style>
    .box {
      background: white;
      height: 150px;
      width: 150px;
    }
  </style>
  
  <script>
    // Wait for the page to load
    $(document).ready(function () {
      
      // Select elements with class "colors" and listen for 'change' events
      $('.colors').change(function () {
        
        // Print to the console the value of the thing (option element) selected
        console.log($(this).val());
        
        // Select elements with the class "box" and style them
        $('.box').css({
          
          // Change the 'background-color' CSS property to the value selected
          'background-color': $(this).val()
        });
      });
    });
  </script>
</head>
<body>
  <div class="box">
    <select class="colors">
      <option value="purple">select purple</option>
      <option value="white">white</option>
      <option value="blue">blue</option>
      <option value="green">green</option>
      <option value="red">red</option>
      <option value="beige">beige</option>
    </select>
  </div>
</body>
</html>
Output 300px

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

Dismiss x
public
Bin info
ebrelsfordpro
0viewers