How do I make this script work with Mozilla browsers?

C

Caledonia_558

Hi everyone,
I'm having trouble with a bit of code to make a paragraph of text
change colour every second to a new, random colour:
Here's the script's function:

<script type="text/javascript">
function change()
{
re="rgb("+Math.round(Math.random()*256)+","+
Math.round(Math.random()*256)+","+Math.round(Math.random()*256)+")"
text.style.color=re;
}
setInterval(change,1000);
</script>

Then you create the text you want to change colour in a paragraph with
id "text":

<p id="text"> Here is where you type your text. </p>

This works beautifully in IE and Opera, but does absolutely nothing in
Mozilla-based browsers. Can I do anything to this script to make it
work in Mozilla browsers?
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top