Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
<head>
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <h2 class="pricetag">Price 1</h2>
  <div class="price">
    <div>
    <div class="inner-price price-out">400</div>
    </div>
    <div>
    <div class="inner-price price-out">400</div>
    </div>
  </div>
  <h2 class="pricetag">Price 2</h2>
  <h2>Price 12</h2>
  <!--comment-->
  <div class="price">
  
    </div>
  </div>
  <h2 class="pricetag">Price 3</h2>
  <div class="price">
    <div>
    <div class="inner-price price-out">250</div>
     <div class="inner-price price-out">250</div>
      
    </div>
    <div>
    <div class="inner-price price-out">250</div>
     <div class="inner-price price-out">250</div>
      
    </div>
  </div>
  <h1>a</h1>
  <div class="a">
    <div>
      <div>
        <h2>Hello</h2>
        <h2>Hello</h2>
        <h2>Hello</h2>
      </div>
    </div>  
    <div>
      <div>
        <h2>Hello</h2>
      </div>
    </div> 
    <div>
      <div>
        <h2>Hello</h2>
      </div>
    </div>
  </div>
 
  
</body>
</html>
 
$(function(){
  $(".price").each(function(){
    if($.trim($(this).find(".inner-price").html())==="")
      $(this).prev(".pricetag").hide();
  });
  
   $('.a').each(function () {
   $(this).find('div div h2 :first-child').clone().appendTo('.pricetag');
    
   });
  
});
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