problem: create element in create element

I

Iulian Ilea

Hello,

I have a problem and I don't understand why this is happening.
Code:
calendar = document.createElement("div");
calendar.setAttribute("id", "calendar");
table = calendar.createElement("table");
After I create table element nothing apears on the screen.

Thanks in advance!
 
I

Iulian Ilea

Iulian said:
Hello,

I have a problem and I don't understand why this is happening.
Code:
calendar = document.createElement("div");
calendar.setAttribute("id", "calendar");
table = calendar.createElement("table");
After I create table element nothing apears on the screen.

Thanks in advance!

Oh... I found :)

calendar = document.createElement("div");
calendar.setAttribute("id", "calendar");

table = document.createElement("table");
calendar.appendChild(table);
 
A

ASM

Iulian Ilea a écrit :
Hello,

I have a problem and I don't understand why this is happening.
Code:
calendar = document.createElement("div");
calendar.setAttribute("id", "calendar");
table = calendar.createElement("table");
After I create table element nothing apears on the screen.

Thanks in advance!

With IE you have to create a tbody before to create tr and tds

of course you appendChild each new element in right place
still to the document.body
 
A

ASM

Iulian Ilea a écrit :
Oh... I found :)

calendar = document.createElement("div");
calendar.setAttribute("id", "calendar");

table = document.createElement("table");
calendar.appendChild(table);

what is that ?
 
I

Iulian Ilea

ASM said:
Iulian Ilea a écrit :

what is that ?

That is the correct way to append an element to a document (from what I
read). If you look in the first post I appended table to calendar.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top