jQuery: position() on created element
Posted
by Parched Squid
on Stack Overflow
See other posts from Stack Overflow
or by Parched Squid
Published on 2010-06-17T19:15:05Z
Indexed on
2010/06/17
19:23 UTC
Read the original article
Hit count: 187
The following code creates a div at the bottom of the page:
var popup = $('<div id="popup" />')
.appendTo('body');
The following code causes it to position correctly once there.
$('#popup')
.position({ my: 'left top', at: 'left bottom', of: $('#someDiv') });
But this code causes it to appear in the DOM but not be positioned anywhere (it is not visible, but it is in the DOM).
var popup = $('<div id="popup" />')
.appendTo('body')
.position({ my: 'left top', at: 'left bottom', of: $('#someDiv') });
Is there a trick to being able to use jQuery position() on an item you are creating?
Cheers, Craig
© Stack Overflow or respective owner