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

javascript

Status
Not open for further replies.

zura

Technical User
Sep 20, 2011
23
GE
HI!
how to change the color of the result of this JavaScript?
>>>

Code:
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content type" content="text/HTML" charset="utf-8"/>

<script type="text/javascript">
{
var d=new Date();
document.write(d.getFullYear();
}
</body>
</html>

>>>
(result is 2011)
 
Add the appropriate HTML or CSS for the color change. Javascript itself cannot change the color of text it outputs.

Code:
document.write("[red]<span style='color:#990000;'>[/red]" + d.getFullYear() + "[red]</span>[/red]");

This would change the text color to red.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 

vacunita.
>>>
thank you for your advice.
>>>
zura.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top