By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,652 Members | 1,441 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,652 IT Pros & Developers. It's quick & easy.

appendChild. Table inside DIV. Doesnt show up

P: 2
I am relatively new to javascript.
I am trying to create a menu. I cant get it to show on IE.
The object exists but just wouldnt show up.
Can anyone please help??
Thanks
:confused:

Expand|Select|Wrap|Line Numbers
  1.         var menuDivNode = document.createElement("DIV");
  2.         menuDivNode.id = "thisMenu";
  3.         menuDivNode.align = "center";
  4.         menuDivNode.style.position = "absolute";
  5.         menuDivNode.style.top = "100";
  6.         menuDivNode.style.left = "500";
  7.         menuDivNode.style.width = "100";
  8.         menuDivNode.style.height = "20";
  9.         menuDivNode.style.backgroundColor = "#FFCF06";
  10.         menuDivNode.style.cursor = "hand";
  11.         menuDivNode.style.zIndex = "1";
  12.  
  13.         var tableNode = document.createElement("TABLE");
  14.         tableNode.border = "1";
  15.         tableNode.cellspacing = "1";
  16.         tableNode.cellpadding = "0";
  17.         tableNode.style.borderCollapse = "collapse";
  18.         tableNode.bordercolor = "#FFCF06";
  19.         tableNode.bgcolor = "#FFCF06";
  20.         tableNode.width = "100%";
  21.         tableNode.height = "100%";
  22.  
  23.         var tableRowNode = document.createElement("TR");
  24.         var tableColumnNode = document.createElement("TD");
  25.         var innerDivNode = document.createElement("DIV");
  26.         innerDivNode.style.fontSize = "9";
  27.         innerDivNode.style.backgroundColor = "#FFCF06";
  28.  
  29.         var menuTitle = document.createTextNode("Rate");
  30.  
  31.         innerDivNode.appendChild(menuTitle);
  32.         tableColumnNode.appendChild(innerDivNode);
  33.         tableRowNode.appendChild(tableColumnNode);
  34.         tableNode.appendChild(tableRowNode);
  35.         menuDivNode.appendChild(tableNode);
  36.         document.body.appendChild(menuDivNode);
Aug 30 '05 #1
Share this Question
Share on Google+
1 Reply


P: 2
Figured it out :D
Requires a TBODY object. Usually it works without this tag in HTML but the DOM requires this object to be defined.
Aug 30 '05 #2

Post your reply

Sign in to post your reply or Sign up for a free account.