I have one variable var result,in this variable I was stored one text-box value,I want to apply the styles for that variable.How to apply styles for variable.Any one help me please.
Asked
Active
Viewed 219 times
0
-
No idea what you're talking about. CSS has no notion of a variable. – BoltClock Apr 19 '13 at 06:24
-
You can't style a variable... you could style that text-box thou – danijel Apr 19 '13 at 06:25
-
If you are talking about css variables see this answer: http://stackoverflow.com/questions/7583076/using-css-variables . I suspect you mean something else ... but it is not clear form your question ... show us some code. – Martin Turjak Apr 19 '13 at 06:28
-
Ya,I want to give style for text-box text which is stored in variable.How to do this?Because i am beginner in css.So please excuse me. – user2159515 Apr 19 '13 at 06:34
2 Answers
0
If you want to set CSS style for text-box(HTML - input type - text) using java script
Try this
<script type="text/javascript">
function changeStyle() {
var cssString = "css style";
document.getElementById("my_Element_id").style.cssText = cssString;
}
</script>
<input type="text" id="my_Element_id" />
<input type="button" value="Change" onlclick="changeStyle()" />
Replace css style to your actual style.

Navnath Godse
- 2,233
- 2
- 23
- 32
0
You can't style a variable.
To style all textboxes you can write something like:
input[type="text"] {
color: red;
}
If you would like to style one specific textbox, give it a class like:
<input type="text" class="my-custom-class" />
And style it with:
input.my-custom-class {
color: red;
}

danijel
- 576
- 4
- 10