...

View Full Version : Styling Markup on the fly



jonathansf
07-13-2006, 06:56 PM
Hi,

I'm creating an H3 element with script like so:

var equip_span = document.createElement("h3");
equip_span.setAttribute("class", "title_equip");

Then in the css I'm styling like this:

h3.title_equip {
font-weight:bold;
font-size:1em;
}

This works great in Firefox but for some reason IE6 does not style the H3. If I change the attribute from "class" to "id" and then style with h3#title_equip, it DOES work in IE.

But, this H3 element is not unique and is created a number of times, so I want it to be a class rather than id. Any ideas why IE is not recognizing the class?

Thanks in advance,
JonathanSF

_Aerospace_Eng_
07-13-2006, 07:07 PM
You need to use className and IE sometimes doesn't like it when you use setAttribute for certain attributes so I recommend the DOM1 method.

var equip_span = document.createElement("h3");
equip_span.className = "title_equip";

jonathansf
07-13-2006, 07:12 PM
That's It!

Thank You!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum