pearlescentcrescent
pearlescentcrescent

Reputation: 143

Offset can't return a div to 0,0?

I'm not sure if I'm having a reference frame problem but I have a pair of div elements pop up next to a target div which has variable positioning.

I'm using a fade, complete combination to hide the divs after a period of time and reset the position of each div to 0,0 however it seems that the reset is not happening

var div = $("#settings");
var position = div.position();
var xcor = position.left;
var ycor = position.top;
$( "#settings" ).offset({ top: ycor-ycor, left: xcor-xcor });
alert('requested offset');

this is part of the function that is called and the alert appears so that indicates to me that the five lines are parsed above.

I have also tried top: -ycor, left: -xcor alternatively I've tried 0,0

I have moved elements in a negative direction before eg. moving upwards by subtracting 1 and using set interval, but I just want to reset these back to 0,0, if there is an easier / more direct way to do that, that would be great... or skip the top-left corner origin idea entirely.

Upvotes: 0

Views: 39

Answers (1)

Frebin Francis
Frebin Francis

Reputation: 1915

Use CSS method of Jquery

 $( this ).css( "top", "topvalue" );

 $( this ).css( "left", "leftvalue" );

Hope this helps.

Upvotes: 1

Related Questions