How can i set a child div to x px left and y px top when adding to another div
HTML
<div id="divContainer"> </div>
Script
$.get(target, function (data) {
$(data).appendTo('#divContainer').css( { left:100,top:200});
});
The get request will give me the markup for another div.
This does not work for me ( positioning to left and top). Any thoughts ?
You'll need to set the position
as well.
$(data).appendTo('#divContainer').css( {position: "absolute",left:100,top:200});
By default, a div
has a position of static
. top
and left
do not affect elements with static position.