[thelist] appendChild() exception

Hassan Schroeder hassan at webtuitive.com
Wed Oct 22 15:47:42 CDT 2003


joe wrote:

> I'm having trouble with a script with a scrip that uses appendChild.  I 
> have a checkbox in a form, which calls a a javascript function when 
> clicked.  the function tries to appendChild() to that element, but IE 
> and Moz aren't having it. the script works fine if I appendChild() to 
> other elements that _aren't_ form controls.

> I've found this exception for appendChild()
> 
>> Exceptions: 
>> DOMException HIERARCHY_REQUEST_ERR
>>     Raised if this node is of a type that does not allow children of 
>> the type of the newChild node,

> but I can't find anywhere that lists exactly what exactly nodes do not 
> allow children or whether form controls are such nodes.  

There's nodes and there's nodes :-)

A node can be one of types TAG, ATTRIBUTE or TEXT.

So you can append an *attribute* to something like a checkbox, but
not append another tag, because <input/> is an *empty* tag -- can't
contain other elements.

You could add a tag node to the parent of the checkbox, though.

HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the thelist mailing list