title: How to change position inside each div using jquery?
body: <p>Scenario: I want to change div.child position inside each div.parent so that div.child appears before 'div.parent .thumbnail'. Right now when I add following code then each parent div get all childs and place them in each div.
  Here is my code:</p>
  
  <pre><code>$( ".parent" ).each(function( index, element ) {
      $( ".child").insertBefore( ".parent .thumbnail" );
  });
  </code></pre>
  
  <p><strong>Result should be like this:</strong></p>
  
  <pre><code> &lt;div class="parent parent1"&gt;
      &lt;div class="child childofParent1"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent1"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="parent parent2"&gt;
      &lt;div class="child childofParent2"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent2"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="parent parent3"&gt;
      &lt;div class="child childofParent3"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent3"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Right now when I run code it appear like:</strong></p>
  
  <pre><code> &lt;div class="parent parent1"&gt;
      &lt;div class="child childofParent1"&gt;&lt;/div&gt;
      &lt;div class="child childofParent2"&gt;&lt;/div&gt;
      &lt;div class="child childofParent3"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent1"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="parent parent2"&gt;
      &lt;div class="child childofParent1"&gt;&lt;/div&gt;
      &lt;div class="child childofParent2"&gt;&lt;/div&gt;
      &lt;div class="child childofParent3"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent2"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="parent parent3"&gt;
      &lt;div class="child childofParent1"&gt;&lt;/div&gt;
      &lt;div class="child childofParent2"&gt;&lt;/div&gt;
      &lt;div class="child childofParent3"&gt;&lt;/div&gt;
      &lt;div class="thumbnail childofParent3"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>