Reputation: 1733
Is there a way to get $element.position()
working for a hidden (i.e. display:hidden
) element?
Upvotes: 1
Views: 2889
Reputation: 1312
Just try
mypos = $('#myelement').css({
visibility: 'hidden',
display: 'block'
}).position();
Upvotes: 2
Reputation: 18078
You could try :
var pos = $element.show().position();
$element.hide();
Only in exceptional circumstances (some untimely interrupt by some process outside the current window/tab), will the element be momentarily rendered.
Upvotes: 2
Reputation: 4812
'display:none;' removes the element from the document so it does not have a position. You could try a quick 'display: block; visibility: hidden;', get the position, and hide it again.
Edit: This is explained on this question's page already: jquery: get the offset of hidden element
Upvotes: 1