If you have another div, you can just get the size + position, for example
var $somediv = $('#some_div_element'),
pos = $.extend({
width: $somediv.outerWidth(),
height: $somediv.outerHeight()
}, $somediv.position());
and then use it when dynamically creating an overlay
$('<div>', {
id: 'overlay',
css: {
position: 'absolute',
top: pos.top,
left: pos.left,
width: pos.width,
height: pos.height,
backgroundColor: '#000',
opacity: 0.50
}
}).appendTo($somediv);
Example: http://www.jsfiddle.net/GkFu4/1/
jAndy source
share