0

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)

3
Contributors
2
Replies
5
Views
9 Years
Discussion Span
Last Post by abanksob1
1
<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>
Votes + Comments
Hey thanks dude.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.