Skip to content Skip to sidebar Skip to footer

Set The Bgcolor Attribute Value

The following doesn't work: Test

Solution 1:

document.getElementById("foo")
                         .setAttribute("style", "background-color: #00FF00;");

width is an attribute. background-color is a style and should be placed as such

Solution 2:

According to the specificationembed has a width attribute but doesn't have a bgcolor attribute.

It is a replaced element anyway, so whatever colour it is, it will take from the Flash object anyway.

Solution 3:

Like Nael said background-color is a style. That said beyond the fact that updating the existing style attribute using setAttribute is very difficult, it's also not very reliable. If your planning on doing anything more involved seriously consider a JavaScript library.

Post a Comment for "Set The Bgcolor Attribute Value"