I have a cell class
.cell {
width:30px;
height:30px;
}
In my createCell function:
var createCell = function(id) {
var div = document.createElement('div');
div.id = id;
div.className = 'cell';
div.addEventListener('click', function() {
div.style.background = pickedColor;
});
document.getElementById('gridArea').appendChild(div);
}
as you can see, i have already assigned className to 'cell'. After calling this function, I call
document.getElementById(id).style.width
It returns empty string ""
Why is it so? how can I retrieve the value immediately after assigning the className?