[thelist] document.createElement?

Peter-Paul Koch gassinaumasis at hotmail.com
Wed Mar 26 10:57:21 CST 2003


>>var a=document.getElementById('contentsUL');
>>var b=a.getElementsByTagName('ul');
>>for(d=0;b[d];d++){
>>  var c=document.createElement('a');
>>alert(c);
>>  a.insertBefore(c,b[d]);
>>}
>
>a is not the parent of c. There's a LI element in between. So the browser 
>tries to find c as a child node of a and fails.

Sorry, should have read: a is not the parent of b[d].

>Solution:
>
>b[d].parentNode.insertBefore(c,b[d]);

--------------------------------------------------
ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
http://www.xs4all.nl/~ppk/
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
W3C DOM Compatibility Table, expanded & updated
http://www.xs4all.nl/~ppk/js/index.html?version5.html
--------------------------------------------------


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail



More information about the thelist mailing list