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
?
//Get var p = $("#elementId"); var offset = p.offset(); //set $("#secondElementId").offset({ top: offset.top, left: offset.left});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With