View Full Version : writing different font depending on comparision result inner.html value

10-07-2012, 03:09 PM

I have got this result


which outputs a number alright. However, I d like to be a bit fancier and want to output it red if it is equal to 5 or smaller and green otherwise.

I know that you change color by document.write(fontcolor("red"))

but I dont know how to embed this last document.write etc into the one I have above

10-07-2012, 03:37 PM
<div id="rent"><div>
var x=3;

Philip M
10-07-2012, 04:01 PM
I know that you change color by document.write(fontcolor("red"))

document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.