Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes CSS class question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "CSS class question." Watch "CSS class question." New topic
Author

CSS class question.

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Is it possible to obtain a Style object in Javascript which represents a defined
CSS class in an external file?

I have a custom control, but I would really hate to have to define the style in code
rather than assign a class name to the DOM node.

I have call back events from the control and I would like to be able to assign a child
node's className equal to its 'selected' style class via getElementById instead of changing
the class object's _defaultCellStyleCSSName and removing/appending the parent control.


Thanks,

Justin


You down with OOP? Yeah you know me!
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I guess another alternative would be to store an actual style of a DOM node in the class.

So for my dataGridCell class:



I could just use that _domElement object in my toDom function as well.
I guess I could assign default classNames (same as actual object class name)
for default and selected/highlighted and just assign the .style, if anything is set
it will trump, if not, default cssclass.

Sound like a good idea?

thanks,

Justin

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61449
    
  67

I have no idea what you are trying to accomplish.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I found what I'm looking for:

document.getElementById("id").style.cssText="value";

Justin
 
Consider Paul's rocket mass heater.
 
subject: CSS class question.