CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   inserting elements, only works with empty parents. (http://www.codingforums.com/showthread.php?t=168018)

Sleeping_Troll 06-03-2009 05:41 PM

inserting elements, only works with empty parents.
 
(Prototype 1.6)

I have the following menu building script:
Code:

function init(){
  for(i=0;i<10;i++){
    menuItems[i]=[];
    menuItems[i].Span=new Element("span",{id:"item"+i});
    $("menu").insert(menuItems[i].Span);
    for(j=0;j<10;j++){
      linkSet[i,j]=[];
      linkSet[i,j].Div=new Element("div",{id:"sub"+j});
      $("item"+i).insert(linkSet[i,j].Div);
  }               
}

Go to this url: http://huduzu.trollnest.com/index1.php

In firebug -> HTML <body>, "content", "menu" You will notice that "item0" and "item1" (which have content) have no children! While "item2" - "item9" (no content) have the children inserted in the script! What am I doing wrong?

The content is created in this script:

Code:

function menuValues(){
  $("item0").textContent="        Webmaster ";
  $("item1").textContent="        Item ";
}

It seems that what is happening here is that when I create the content for "item0" and "item1", I am wiping out the child elements. Any DOM experts out there?


All times are GMT +1. The time now is 12:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.