Span with if- urgent!

Yes, but I want it red if it is greater then 10 and be if inputted var is smaller than 10…so I need sth like “if statement” inside docment.write() or?

Yes, that is correct.

Lets put what you said in as code.

if (a > 10) {
    color = 'red';
} else if (a < 10) {
    color = 'blue';
}
var coloredText = colorText('var a: ' + a, color);
document.getElementById('demo').appendChild(coloredText);

You’ll just need some css classes with that, such as:

.red { color: red }
.blue { color: blue }

This writes 8 var a: // red 8

But I want the opposite: var a: 8

Please, how to achive this?

Please,how should I write the syntax?

What do you mean by “this” ? It can have many meanings.

These are words we even did not mention.
Is there no easier way please?

P.s. I try to find it made clear in tutorials…w3schools has too easy examples and Yours are TOO COMPLICATE… i need sth invetween

We are happy to help with peoples understanding here, but doing the homework for them is something that we are generally opposed against.

I ment as : var a: 8 instead 8 var a;

My code does 8 var a:

and I want : var a: 8

This is not ment as object here

You may have to make your request more clearly understood. There is little that can be gleaned from what you were just saying here right and now.

Please, can someone send me a usefull link?
Is there an example how to make an object of an ELEMENT? ( i ment span as element)

This code writes
8 var a:

But I want
var a: 8

http://pastebin.com/UwpgfR2p

What is the code that you are using, that results in the above trouble?

That would be as follows:

var span = document.createElement('span');

That one from pastebin, can U see this?

http://pastebin.com/UwpgfR2p

I am thinking how to make psedocode at all.
Can U open my pastebin link?

http://pastebin.com/UwpgfR2p

There’s a problem with how you are using document.write.

You have the demo div in the body of the document, and the problem is that you are then using document.write to add other stuff to the end.

By the way - what’s supposed to happen when the number is exactly 10?

We have to get the kind of output we can achieve just with document.write.

Which output woudl U suggest?
I tried all outputs from w3school and document.write() is the only one that looks like it is ment in tasks?

It is not that important, problem is I have to get just the bigger number collored one color and smaller colored another color.

But text in front of the number should stay black…

If you’re forced to use document.write, then you are going to be forced to do things the bad way.

The bad way being where you have no body content at all, and the entire content of the page is written all at once from the document.write as if it were a stream of HTML text that you are dumping to the page, because that’s precisely what you will be doing.