I am trying to overlay an existing div with a new dynamically created div with same dimensions. I try to set the height and width for the new div dynamically using the existing divs height and width. I am getting the dimensions of the existing div in divSize array and I pass the same to the generateDiv function
Upon inspecting the element i find that It does not add the height and width property values to the CSS. What am I doing wrong here Am I missing something any help would be much appreciated May code is as follows:
function generateDiv(divSize, divContent, object) {
$('<div class="divOverlay">' + divContent + '</div>').css({
'width': divSize[0] + 'px !important',
'height': divSize[1] + 'px !important',
'background-color': '#ddd',
'position': 'absolute',
'color': '#56D9C9',
'margin':'7px 7px 7px 0px',
'zIndex': '100'
}).appendTo($("#" + object).css("position", "relative"))
}