Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
<style>
  .content {
     border:2px solid black;
   margin:20px;
   min-height: 40px;
  }
  
  #clone {
     border:2px solid tomato;
   margin:20px;
   min-height: 40px;
  }
</style>
  </head>
  <body>
<div class="content" id="content1">
    content 1
</div>
 
<div class="content" id="content2">
    content 2
</div>
 
<div id="clone">Clone</div>
    
<input type="button" value="replaceAll" id="btn1" />
<input type="button" value="replaceWith" id="btn2" />
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
<script>
 $('#btn1').click(function(){
        $('#clone').clone().replaceAll('#content1');
    })
    $('#btn2').click(function(){
        $('#content2').replaceWith($('#clone').clone());
    })
</script>
  </body>
</html>
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