views:

36

answers:

2

Hi,

I have the following part of DOM:

<div id="content">
  <div id="div-1"></div>
  <!-- here new DOM -->
  <div id="div-2"></div>
</div>

I need to insert new part of DOM between "div-1" and "div-2".

How I can do it with jQuery?

+4  A: 

use .after() on div-1

$('#div-1').after('<div id="new">new div</div>');

or use .before() on div-2

$('#div-2').before('<div id="new">new div</div>');
Reigel
Thanks man, it works!
Alex Ivasyuv
+1  A: 
$('#div-1').after('<div>new content</div>')'

or

$('<div>new content</div>').insertAfter($('#div-1'));
Toby