var open = false;
function toggleOpenClose()
{
var container = document.getElementById('container');
if (open) {
// close
dump("\n\n\n\nCLOSING\n\n");
container.removeChild(container.firstChild);
}
else {
// open
dump("\n\n\n\nOPENING\n\n");
var frame = document.createElement('box');
frame.setAttribute('align', 'vertical');
frame.setAttribute('style', 'width: 50px; height: 50px; background: red;');
container.insertBefore(frame, container.firstChild);
}
open = !open;
}
Add/Remove Red Element At 0
The order should stay 'blue, green, yellow'.