Alper
Alper

Reputation: 1

How do I change the color of javascript text?

So I have some JavaScript that creates separate text.

When I call it, to make the typing text, I do something like:

<center><p id="w00t"><font color="white">text here</font></p></center>

<script type="text/javascript">

new TypingText(document.getElementById("w00t"), 50, function(i){ var ar = new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; });

//Type out examples:
TypingText.runAll();
</script>

But, the background of my webpage is black, and it prints the line ending array:

new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; });

as black.

How would I make it white?

Upvotes: 1

Views: 8383

Answers (4)

SeanCannon
SeanCannon

Reputation: 77956

Since I'm assuming you're old school with the <font> tag, etc., add this to your <head> so it looks something like this:

<head>
    <style type="text/css">
        body {
            background-color:#000; // background color black
            color:#FFF; // font color white
        }
    </style>
</head>

Upvotes: 0

Paul Sonier
Paul Sonier

Reputation: 39480

Use CSS styling. Set the style.color of the element to the color you want.

Upvotes: 0

brenjt
brenjt

Reputation: 16297

First of all I would be careful of what tags you use. <center><font> have both been deprecated and soon won't be supported.

Use classes or styles to change the text color.

#w00t
{
color:white;
}

Upvotes: 0

thesonglessbird
thesonglessbird

Reputation: 570

Remove the font tag first and foremost. It's not used anymore and you certainly don't need it in this case.

To colour the text, use the following code:

document.getElementById("w00t").style.color = "#FFFFFF";

Upvotes: 1

Related Questions