Change text color for one document.write but not color of all text?

Guest

I want to make the date at the top right darker blue.
But when I do that, all the light blue text next to
the pictures also changes.

How can I control the color of the result of
document.write output without changing the
forground color of the entire page? Note my
document write includes variables, so I was
hesitant to imbed an html command in the
document.write.

Advertisements

<> wrote in message
news:...
> Hi, one part of my website is at:
>
> http://www.psych.nmsu.edu/~jkroger/lab/undergrads.html
>
>
>
> I want to make the date at the top right darker blue.
> But when I do that, all the light blue text next to
> the pictures also changes.
>
> How can I control the color of the result of
> document.write output without changing the
> forground color of the entire page? Note my
> document write includes variables, so I was
> hesitant to imbed an html command in the
> document.write.
>
> Thanks much in advance for any pointers....
> Jim
>

Advertisements

wrote:
> Hi, one part of my website is at:
>
> http://www.psych.nmsu.edu/~jkroger/lab/undergrads.html
>
>
>
> I want to make the date at the top right darker blue.
> But when I do that, all the light blue text next to
> the pictures also changes.
>
> How can I control the color of the result of
> document.write output without changing the
> forground color of the entire page? Note my

Wrap it in a <span> with the appropriate colour. Your
"get date" function is a bit rough too, suggested
improvement below.

Using arrays for months and days is considerably more
efficient than your multiple if's.
> document write includes variables, so I was
> hesitant to imbed an html command in the
> document.write.

HTML is not "commands", it is markup that is interpreted.
It may seem a trivial point, but there you go. You have
no other way of controlling the colour of the element
than using markup, so use it. I have used a span and style,
but you could use a class too.

Re: Change text color for one document.write but not color of alltext?

RobG wrote:
> wrote:
>
>>Hi, one part of my website is at:
>>
>>http://www.psych.nmsu.edu/~jkroger/lab/undergrads.html
>>
>>
>>
>>I want to make the date at the top right darker blue.
>>But when I do that, all the light blue text next to
>>the pictures also changes.
>>
>>How can I control the color of the result of
>>document.write output without changing the
>>forground color of the entire page? Note my
>
>
> Wrap it in a <span> with the appropriate colour. Your
> "get date" function is a bit rough too, suggested
> improvement below.
>
> Using arrays for months and days is considerably more
> efficient than your multiple if's.
>
>
>>document write includes variables, so I was
>>hesitant to imbed an html command in the
>>document.write.
>
>
> HTML is not "commands", it is markup that is interpreted.
> It may seem a trivial point, but there you go. You have
> no other way of controlling the colour of the element
> than using markup, so use it. I have used a span and style,
> but you could use a class too.
>
>
>
> <html>
> <head>
> <title>play</title>
> <script type="text/javascript">
>
> function clientDate(){
> var months = ['January','February','March',
> 'April','May','June','July',
> 'August','September','October',
> 'November','','December'];

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!