Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
  <style>
    .container {
      border: 1px solid red;
      background-color: #e0e0e0;
    }
  </style>
</head>
<body>
  <div class="first">first</div>
  <div class="second">second</div>
  <div>Neither first nor second</div>
  <div class="first">first</div>
  <div class="second">second</div>
  <div>Neither first nor second</div>
</body>
</html>
 
(function($) {
  
  var current;
  
  $(".first, .second").each(function() {
    var $this = $(this);
    if ($this.hasClass('first')) {
      current = $('<div class="container"></div>').insertBefore(this);
    }
    current.append(this);
  });
  
})(jQuery);
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers