English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi I have a list elements inside a div. I have javascript function to dynamically add list elements to the div using (appendChild).

I have another javascript function to enumerate the list items.

Now. For the list items that originally exists in the page, enumerate function work. But when I start to add list elements dynamically, they do not get enumerated. I also noticed that when I view the page source, the newely added elements are not shown.

Can somebody help me with a way to keep track of the updated list elements?

function Enumerate()
{
var mylist = document.getElementById('firstlist');
for (i=0; i if (mylist.childNodes[i].nodeName=="LI")
alert(mylist.childNodes[i].innerHTML);
}
}

2007-03-11 09:23:19 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

a couple of things

1) if you use firefox, and select the added items on the page, then right click you can see whats going on with the dynamic elements. they never show in a simple view source.

2) it depends where you dynamically added them! If the code doesn't get them, they may not have been legitimate children!

2007-03-11 10:02:26 · answer #1 · answered by jake cigar™ is retired 7 · 0 1

i imagine you want to run a particular javascript code each and anytime the web page includes factors with particular training and/or ids. Or have this will not be able to be accomplished. on your first party, td { onclick: some javascript } i visit signify, you call a js function on onload of the table which does, var d = record.getElementsByTagName('td'); for (var t in d) { t.onclick = "some javascript"; } or a modification of that. note: onclick isn't a css type. its a html aspect sources. css can in reality regulate the form sources of html factors @fallendownsince2005 Mr. Lund isn't incorrect. he did not say javascript won't be able for use for client aspect scripting, he stated CSS won't be able for use. (perhaps he edited it later) @PSP your 'answer' is thoroughly on a diverse plane altogether.

2016-12-01 20:28:11 · answer #2 · answered by Anonymous · 0 0

Edit your code to include some spaces so we can read it in its entirety.

2007-03-11 09:29:40 · answer #3 · answered by Rex M 6 · 0 1

fedest.com, questions and answers