[thelist] document.createElement?

Kae Verens kverens at contactjuggling.org
Tue Mar 25 09:53:11 CST 2003


trying some funky stuff, but falling down on the first hurdle...

I try this code (in Mozilla):

var c=document.createElement('a');
alert(c);

yet the alert comes out blank...

When I alert the tagName, it correctly gives me 'A', but the element 
seems to be unusable in a normal sense. The next step in what I was 
doing was something like this:
a.insertBefore(c,b[d]);

but, I get an error that the node (presumably c) is not found.

Any ideas?

sample HTML:
<ul id="contentsUL">
  <li>
   <ul>
    <li></li>
   </ul>
  </li>
  <li>
   <ul>
    <li></li>
   </ul>
  </li>
</ul>

sample ECMAScript:
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]);
}

-- 
Kae  Verens +----------------------------------+ webworks.ie
        pay  |      http://www.webworks.ie      |  bee
    play     |  http://www.contactjuggling.org  |     boss
kae         |http://kverens.contactjuggling.org|         god



More information about the thelist mailing list