Wednesday 26 October 2011

How can I change the color of text using Javascript?

This is my code:



%26lt;script language=%26quot;javascript%26quot;%26gt;

var FirstName=prompt(%26quot;Please Type Your First Name Here%26quot;);

var LastName=prompt(%26quot;Please Type Your Last Name Here%26quot;);

var ShoeSize=prompt(%26quot;Please Type In Your Shoe Size Here%26quot;);

var Gender=prompt(%26quot;What Is Your Gender? (Male Or Female)%26quot;);



document.write(%26quot;Your Name Is: %26quot; + FirstName + %26quot; %26quot; + LastName + %26quot;%26lt;br%26gt;%26quot;);

document.write(%26quot;Your Shoe Size Is: %26quot; + ShoeSize + %26quot;%26lt;br%26gt;%26quot;);

document.write(%26quot;Your Gender is: %26quot; + Gender + %26quot;%26lt;br%26gt;%26quot;);



if (Gender == %26quot;Male%26quot; || %26quot;male%26quot;)

{

document.write(%26quot;Your Luck Number Is: %26quot; + (FirstName.length + LastName.length) * ShoeSize);

}

else

{

document.write(%26quot;Your Luck Number Is: %26quot; + (FirstName.length + LastName.length) * ShoeSize);

}



%26lt;/script%26gt;



I would like it so when the end result is shown on the screen where is says %26quot;Your Luck Number Is%26quot; for the answer to be in a different color. How would I do this?



Thanks
How can I change the color of text using Javascript?
document.write(%26quot;Your Luck Number Is: %26lt;font color=\%26quot;red\%26quot;%26gt;%26quot; + (FirstName.length + LastName.length) * ShoeSize + %26quot;%26lt;/font%26gt;%26quot;);