views:

20

answers:

1

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

+1  A: 

Hi,

try this:

var popup = $('<div id="popup" />')
    .position({ my: 'left top', at: 'left bottom', of: $('#someDiv') })
    .appendTo('body');

Grz, Kris.

XIII
Awesome, thanks XIII
Parched Squid