Tuesday, April 21, 2020, 10:58 PM
Posted by Administrator
#edutech #college #work #NFT #education #remotework #onlinelearning #stem #talent #diversity #highered #STEM #blogPosted by Administrator
Q: How can I set the CSS background color of an HTML element using JavaScript?
A: 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;
}
// where el is the concerned element
var el = document.getElementById('elementId');
setColor(el, 'green');
1 comment
( 233 views )
| permalink
| ( 3.1 / 581 )