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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling CSS in Javascript

Status
Not open for further replies.

hiyatran

Technical User
Aug 7, 2010
21
CA
in HTML you can call CSS

Code:
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<tr><td class="cssHere">Display</td></tr>

can you even call CSS in javascript?
Code:
document.writeln("<tr><td class="cssHere">" + Display + "</td></tr>");

if so how do you even call the "style.css"

thanks

 
Hi

What you are showing in your example is not setting the style, but setting the class. In JavaScript that is simple :
Code:
reference_to_your_element[teal].[/teal]className[teal]=[/teal][green][i]'name_of_your_class'[/i][/green]
If you really want to set the style, that is also simple, but was not supported in all browsers :
Code:
reference_to_your_element[teal].[/teal]style[teal].[/teal]cssText[teal]=[/teal][green][i]'your css rules'[/i][/green]


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top