Thanks Per.

A JS function to do what I want might look something like this:

insertChildNode(element, parent, index)
{
    var children = parent.elements;
    if(index == 0)
    {
        parent.insertBefore(element, parent.firstChild); // Note, in
JS, this works if parent.firstChild is null
    }
    else if(typeof(index) != 'undefined' && index < elements.length -
1)
    {
        parent.insertBefore(element, elements[index])
    }
    else
    {
        parent.appendChild(element) // Default behavior with no index
or index >= elements.length
    }
}

The above assumes that elements, insertBefore, appendChild, and
firstChild work the same in all browsers (yes, I know they should.)
It also represents a task so common that it seems a natural for
standardization in a framework such as MochiKit.

Just my 2 cents.

MJ

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to