This was much harder than I expected. You'd think there'd by an element.removeAllChildren() function. Note you have to remove the children in reverse order as the array changes as you delete elements.

I've put this function in a JS file in =common/DO.js=

      kids = some_parent.childNodes;
      nNodes = kids.length;
      if (kids)
      {
         for (var i = nNodes - 1; i >= 0; i--)
         {  some_parent.removeChild(kids[i]);
         }
      }

-- MattWalsh - 21 Mar 2007

Topic revision: r2 - 30 Mar 2007 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback