How do I change the style (color) of a div such as the following?
"<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>">
<%= ((foo.isTrue) ? foo.Name: "false foo") %>"`
How do I change the style (color) of a div such as the following?
"<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>">
<%= ((foo.isTrue) ? foo.Name: "false foo") %>"`
If you want to alter the color of the div with client side code (javascript) running in the browser, you do something like the following:
That code fragment doesn't say much - if the code is server-side why don't you change e.g. the class of the HTML element there?
Try this: in the .aspx file put thees lines
then you can use for example
IMO this is the better way to do it. I found some of this in other posts but this one comes up first in google search.
This part works for standard JavaScript. I am pretty sure you can use it to remove all styles as well as add/overwite.
OR
This works for jQuery only
If you wanted to change the class instead of the style directly: ie.. create another class with the styling you want...
Generally, you can do it directly
document.getElementById("myDiv").style.color = "red";
There's a reference here.