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?
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";
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;
}
Use CSS styling. Set the style.color of the element to the color you want.
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>
精彩评论