Changing button color programmatically

Zsolt picture Zsolt · Nov 30, 2009 · Viewed 130.5k times · Source

Is there a way to change the color of a button, or at least the color of the button label programmatically? I can change the label itself with

document.getElementById("button").object.textElement.innerText = "newlabel";

But how to change the color?

Answer

Maurizio Pozzobon picture Maurizio Pozzobon · Nov 13, 2010

I have finally found a working code - try this:

document.getElementById("button").style.background='#000000';