Forum Moderators: open

Message Too Old, No Replies

Dynamic Page Elements

Using DOM and createElement

         

JohnCanyon

6:34 am on Aug 2, 2006 (gmt 0)

10+ Year Member



Is it possible to dynamically name div tags using DOM in order to replace that content later?

The only examples I have been able to find refer to elements that already exist on the .html page.

What I am trying to do is dynamically update childrens children nodes into the dynamic result set that has already been appended to the body.

Hope there are some of you less confused then me at the moment, thanks in advance for the guidance.

John

[edited by: JohnCanyon at 6:35 am (utc) on Aug. 2, 2006]

daveVk

7:54 am on Aug 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dynamicly generated elements can be referenced in the DOM in identical way to those in original source. Is there more to the question?

JohnCanyon

2:36 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



Dave, ok.. so it is possibe. This is great news. I guess the next thing to know is how might I assign an ID to the div tags for further reference.

The code i am playing around with looks like this.

var divContainer = document.createElement("div");
var divContent = document.createElement("div");
divContent.appendChild(document.createTextNode(SomeContent));
divContainer.appendChild(divContent);
oFragment.appendChild(divContainer);
document.body.appendChild(oFragment);

As you can see, this simply creates a div tag with no identifiable attributes for further update. Any further help is appreciated. I will continue to research this with fresh eyes.

Cheers,

John

[edited by: JohnCanyon at 2:37 pm (utc) on Aug. 2, 2006]

JohnCanyon

4:09 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



Thanks for your help Dave. I figured out how to allocate IDs.

setAttribute();

Cheers,

John