jQuery replace multiple elements using class
<p>I want to replace all the <code>spans</code> with a <code>div</code>.
When I run this code only one element gets replaced.
How to change this code so that the script affects all the <code>spans</code>?</p>

<p><em>I have tried to use clone(), but it didn't work.</em></p>

<pre><code>$flexBox = $("&lt;div&gt;&lt;/div&gt;");
$(".overlayBox").replaceWith($flexBox);

&lt;span class="overlayBox"&gt;&lt;/span&gt;
&lt;span class="overlayBox"&gt;&lt;/span&gt;
&lt;span class="overlayBox"&gt;&lt;/span&gt;
</code></pre>
