aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Applying style to a variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Applying style to a variable" Watch "Applying style to a variable" New topic
Author

Applying style to a variable

K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
I want to apply several styles to a javascript variable:font, size, color, etc. How do I apply all the styles to one variable?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

What does it mean to apply a style to a variable?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Sorry for the lack of info.

Basically, I have an app that is returning a value to be displayed on a html page. I want to apply formatting directly to that value.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
well you would have to add it either building a string and using innerHTML or using dom methods with createElement and setAttribute()

Eric
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
I use innerHTML this way: ; but I am not sure how to add the formatting to it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

In other words, the style gets applied to the element that you set the data within, not the variable.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You know how to do it with normal HTML? If you do, buyild up a string that looks like that.

Eric
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Applying style to a variable