Question
How can I set the CSS background color of an HTML element via JavaScript?
Answer
In general, CSS properties are converted to JavaScript by making them camelCase without any dashes. So background-color becomes backgroundColor.
function setColor(element, color)
{
element.style.backgroundColor = color;
}
< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/3319/" >CSS background color in JavaScript< /a>
0 comments:
Post a Comment