Reputation:
I would like to change the color of a particular grid field.I don't know how to add gridColumnStart and gridRowStart to my line of code.
document.getElementsByClassName('grid').style.backgroundColor ="#FE2E64";
Upvotes: 1
Views: 374
Reputation: 12891
document.getElementsByClassName('grid')
returns a HTML collection - which essentially is an array. It doesn't have a style property. Instead you must loop over the elements inside the array and change the style of those.
var myGrid = document.getElementsByClassName('grid');
for(var a=0;a<myGrid.length;a++)
{
myGrid[a].style.backgroundColor ="#FE2E64";
}
If grid is the ID of an acutal html element, you can't use getElementsByClassName() at all. In this case use
document.getElementById("grid")
Upvotes: 1