Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applying style to a variable

 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean to apply a style to a variable?
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use innerHTML this way: ; but I am not sure how to add the formatting to it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, the style gets applied to the element that you set the data within, not the variable.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know how to do it with normal HTML? If you do, buyild up a string that looks like that.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic