Hey. I'm looking for a solution that will create, fill and display a container in javascript directly beneath a specific element (no whitespace, margins w.e)

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script type="text/javascript"><!--
function insertAfter(parent, newNode, referenceNode)
{
	parent.insertBefore(newNode, referenceNode.nextSibling);
}
window.dynamicNodeCount=0;
function addElement()
{
	window.dynamicNodeCount++;
	var dad = document.getElementById('container');
	var elementAboveNew = document.getElementById('sib1');
	var newElement = document.createElement('div');
	newElement.innerHTML="Element " +window.dynamicNodeCount;
	insertAfter(dad,  newElement, elementAboveNew);
}
//--></script>
<div onclick="addElement();">Add Element</div>
<div id="container">
	<div id="sib1">a</div>
</div>
</body>
</html>
Comments
Hey thanks dude.
This article has been dead for over six months. Start a new discussion instead.