¿Algo así?
Código PHP:
<html>
<head>
<script type="text/javascript">
function addNode(id){
var obj = document.getElementById(id);
var p = obj.getElementsByTagName('p');
var addP = document.createElement('p');
addP.innerHTML = 'Foo' + (parseInt(p.length) + 1);
obj.insertBefore(addP, p.item(0));
}
</script>
</head>
<body>
<input type="button" value="Añadir nodo" onclick="addNode('nodes');" />
<div id="nodes">
<p>Foo1</p>
</div>
</body>
</html>