how to append a new div between each img tag using jquery?
<p>This is my code:</p>

<pre><code>    &lt;div class="sample"&gt;
    &lt;img src="images/i1.jpg"/&gt;
    &lt;img src="images/i2.jpg"/&gt;
    &lt;img src="images/i3.jpg"/&gt;
    &lt;/div&gt;
</code></pre>

<p>i want to append like this but class should be created and append dynamically using jquery:I tried but my logic is wrong so anyone help</p>

<pre><code>        &lt;div class="sample"&gt;
    &lt;div class="new"&gt; &lt;img src="images/i1.jpg"/&gt; &lt;/div&gt;
    &lt;div class="new"&gt; &lt;img src="images/i2.jpg"/&gt; &lt;/div&gt;
    &lt;div class="new"&gt; &lt;img src="images/i3.jpg"/&gt; &lt;/div&gt;
    &lt;/div&gt;

    $('img').each(function(){ 
var that = $(this);    
var v = document.createElement('div');
v.setAttribute('class','new');
$(v).append(that);
$('sample').append(v);
});
</code></pre>
