Insert Elements Around All Matching Elements .wrapAll()

.wrapAll(element)

element: {selector, html String, Element, jQuery Object | Function(index){...}}
e.g. $("span").wrapAll("<div>")

.wrapAll(element) will insert element around all elements in the matched set.

Example 1: $("b").wrapAll("<div>") will insert <div>...</div> around all <b>.
Before
<b>A</b>
<b>B</b>
After
<div>
  <b>A</b>
  <b>B</b>
</div>
Example 2: $("b").wrapAll("<div><span>") will insert <div><span>...</span></div> around all <b>.

Before

<b>A</b>
<b>B</b>
<p>
  <b>C</b>
</p>

After

<div>
<span>
  <b>A</b>
  <b>B</b>
  <b>C</b>  // moved 
</span>
</div>
<p></p>

jQuery manipulation insertion .wrapAll()