beck5
beck5

Reputation: 71

Use string variable as color

What I am trying to do is have something like this

var myVar = "blue"

then do

document.body.style.color = myVar

so the color of body is blue.

Could anyone help me?

Upvotes: 0

Views: 170

Answers (1)

IrkenInvader
IrkenInvader

Reputation: 4050

That will work to make the text blue. If you wanted to change the background color use backgroundColor

document.body.style.backgroundColor = myVar;

Upvotes: 7

Related Questions