I'm trying to use jQuery to detect the position of a div (#olddiv
), so I can use that position to place another div (#newdiv
) exactly below it. The right borders of the 2 divs are aligned (right border).
I'm trying to get the #olddiv
bottom and right locations to use them as the #newdiv
top and right borders. I've used this code, but it's not working. Any idea what I'm doing wrong?
var right = $('#olddiv').position().right;
var top = $('#olddiv').position().bottom;
$('#newdiv').css('top', right);
$('#newdiv').css('right', top);
Also, I'm not sure if position
is what I need. I think this can be done with position
or offset
, but I'm not sure:
$('#ID').position().left
$('#ID').offset().left
Thanks