Re: node.insertBefore( child )

Hi,

On Wed, 2003-12-03 at 19:34, Chris Moschini wrote:
> for( i = 0; i < len; i++ ) {
>   if( node.childNodes.length == 0 )
>     last = node.appendChild( list[ i ] );
>   else
>     node.insertBefore( list[ i ], last );
> }

what about

for( i = 0; i < len; i++ )
  node.insertBefore(list[i], node.firstChild());

?
ok there are two method calls instead of only one but I think this is
acceptable (and inserting at the beginning of the list is IMHO less
common than appending)

-- luca

Received on Wednesday, 3 December 2003 14:29:21 UTC