Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get and set position with jQuery .offset()

Tags:

jquery

How to get and set the position of an element with the jQuery .offset method?

Let's say I have a div layer1 and another layer2. How can I get the position of layer1 and set the same position to layer2?

like image 883
Denise Avatar asked Jan 06 '11 09:01

Denise


1 Answers

//Get var p = $("#elementId"); var offset = p.offset();  //set $("#secondElementId").offset({ top: offset.top, left: offset.left}); 
like image 56
Steve Avatar answered Sep 28 '22 04:09

Steve