var yourVar; // some DOM instance
var newFirstElem; //element which should be first in yourVar
yourVar.insertBefore(newFirstElem, yourVar.firstChild);
THis will add as the first child. To add after just use normal append.
Edit:
Consider you have this in the beginning:
<div class="blabla">
<div class="ABCD">
</div>
</div>
And you want to add
<ul class="abcd" id="abcd></ul> to div with class ABCD
$(".ABCD").append('<ul class="abcd" id="abcd></ul>')
You want to add to div with class blabla
$(".blabla").append('<ul class="abcd" id="abcd></ul>')
Consider you have already have this this
<div class="blabla">
<div class="ABCD">
<ul class="abcd" id="abcd></ul>
</div>
</div>
and now you want to add before the ul inside the div with class abcd
$(".abcd").prepend("<ul class="abcd" id="abcd></ul>");
jQuery makes it simpler. You can just use prepend function. This function allows you to insert whatever you like at the beginning. There are also the option of inserting at specific positions. You should take a look at:
insertAt
insertBefore
after
before