<div id=div1></div> <p id=p1></p> <p id=p3></p> <p id=p2></p>
$('#p1').before($('#div1')); $('#p3').after($('#p2'));
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> </head> <body> <p id=p1>1</p> <div id=div1>test</div> <p id=p2>2</p> <p id=p3>3</p> <script> p1.parentNode.insertBefore(div1, p1); </script> </body> </html>
div1.parentNode.insertBefore(div1, div1.previousElementSibling);