hi i would like to change just part of my code to change the color of my answer to my maths game see the code

document.write("<br>3+2 = " + answer1 + " is incorrect - the correct answer is 5");

see where it says the answer is 5 i would like to change it to red but cant find how to do it

thanks

Member Avatar for iamthwee

In your .css

Create a class called red. Then assign the red tags around the number five.

http://jsfiddle.net/WCzeb/

hi just tried that and not working??

hi i would like to change just part of my code to change the color of my answer to my maths game see the code

document.write("<br>3+2 = " + answer1 + " is incorrect - the correct answer is 5");

see where it says the answer is 5 i would like to change it to red but cant find how to do it

thanks

document.write(
      "<br>3+2 = "+answer1+" is incorrect! - "+("The correct answer is 5.").fontcolor('red'));

excellent thanks also is it the same for this one??

document.write("<br>25-15 = " + answer10 + " The answer is correct ");

Yes, but I would use "green" color for the correct one :p

ekkkkk that dont work lol

document.write("<br>3+2 = " + answer1 + "+("The answer is correct").fontcolor('red'));

What don't work?!!
that don't work because you also lack copy-paste skills

i tryed putting the same code for the one above

i wanted "the answer is correct" to be red too

so what?
I never gave you the green code version for you to go "ekkkkk"
-how hard can it be to simply replace content from this:

document.write("<br>3+2 = "+answer1+" is incorrect! - "+("The correct answer is 5.").fontcolor('red'));

to this:

document.write("<br>3+2 = "+answer10+(" The answer is correct ").fontcolor('red'));

or removing the parens altogether since they may be confusing instead of helping

document.write("<br>3+2 = "+answer1+" is incorrect! - "+"The correct answer is 5.".fontcolor('red'));
document.write("<br>3+2 = "+answer10+" The answer is correct ".fontcolor('red'));

thanks very much i think it was confusing matters with the parens, didnt no whether to put it before or after them...thanks

now you see how easy it was, you should be more patient when asking people for help giving nothing in return, so even if their given code may prove to be wrong - never go "eeekkk" on them because even then, they've done it with their best intentions and were only trying to help by offering the best they've got.
'Cause you see, you didn't even bother to mark the tread as solved, even though there is no other method for changing the color of the string in place and on the fly, so that others may benefit too.

stay cool.

thanks for all your advise how do i make it as solved??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.