views:

13

answers:

1

I am creating some elements in javascript like so:

var parent = document.createElement('div');
parent.setAttribute('id', 'parent');

var child = document.createElement('div');
child.setAttribute('class', 'child');

parent.appendChild(child);
otherelement.appendChild(parent);

I have a stylesheet which has styles for #parent and .child. However, it appears the styles are being applied to the parent but not the child. Does ie6 only support styles on id's and not classes or am I doing something wrong?

+1  A: 

Stupid mistakes slipping my mind. Fixed it with the following code:

parent.id = 'parent';
child.className = 'child';
rickharrison