Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS with Javascript??

Status
Not open for further replies.

hiyatran

Technical User
Aug 7, 2010
21
0
0
CA
I am able to incorporate CSS into the HTML, like this:
Code:
<tr><td [B]style="background-color:#FFFF00;"[/B]>test</td></tr>

How can I incorporate CSS into javascript?
Code:
document.writeln("<tr><td [B]style="background-color:#FFFF00;"[/B]>" + "test" + "</td></tr>");

The javascript code doesn't work or this is it even possible?

Thanks

 
Use javascript to dynamically change the style by adding an id to your td:

HTML:
Code:
<td id="test" style="background-color:#FFF000">test</td>

JAVASCRIPT:
Code:
document.getElementById("test").style.backgroundColor = "#FF1166";

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top