title: How to append div just after main div?
body: <p>How to append div just after main div</p>
  
  <p>jQuery Code</p>
  
  <pre><code>var $icons = $('.error + .i-icon-div');
  if ($icons.length) {
      $icons.each(function () {
          var $this = $(this);
          $this.appendTo($this.prev())
      })
  }
  </code></pre>
  
  <p>Html Code</p>
  
  <pre><code>&lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="i-icon-div"&gt;Lorem Ipsum&lt;/div&gt;
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>&lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
      &lt;div class="i-icon-div"&gt;Lorem Ipsum&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Need output like that</p>
  
  <pre><code>&lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="error"&gt;
      &lt;input type="text" name="email" /&gt;
      &lt;div class="i-icon-div"&gt;Lorem Ipsum&lt;/div&gt;
      &lt;div class="error-message"&gt;Please Enter Email&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have discuss some similar here <a href="https://stackoverflow.com/questions/21621134/remove-div-if-exits-after-div-and-put-inside-the-main-div">Remove div if exits after div and put inside the main div</a>  </p>