[Javascript] DOM: adding CSS to created DIV

David Dorward david at dorward.me.uk
Mon Jan 22 03:55:59 CST 2007


On Mon, Jan 22, 2007 at 09:50:36AM +0100, Michael Borchers wrote:

> >AFAIK it will, I've never used it (as setting a .className has usually
> >done the trick for me when I wanted to set lots of styles at once).

> before i try: creating the div "on the fly" and just adding the
> class name as attribute 

As mentioned, IE's support for setAttribute is lacking. Set the
.className property instead.

> would be enough to see the div with the
> styles i have adjusted to the CSS class?

There is no such thing as a "CSS class". Classes are part of HTML. CSS
has "class selectors" which (along with the other selectors in CSS)
control what elements a declaration-block applies to.

Making an HTML element a member of a class will cause styles in any
declaration-block associated with a selector that matches that class
to be applied on the fly though.

-- 
David Dorward                                      http://dorward.me.uk




More information about the Javascript mailing list