[jQuery] wrap - DOM Insertion, Around

$('#btn0').click(function(){
  $('#rect0').wrap('<div class="red-border"></div>');
});

.wrap( html:string )
要素を、指定htmlで囲む

要素で囲む

$('#btn1').click(function(){
  $('#rect1').wrap( $('.red-border') );
});

.wrap( selector )
要素を、指定セレクタで囲む

要素で囲む

$('#btn2').click(function(){
  $('#rect2').wrap( function(index){
    return '<div class="red-border"></div>';
  } );
});

.wrap( function(index:int){} )
要素を、functionの返り値で囲む

要素で囲む