Repositioning Elements

$("#up").on("click", function(){   var offset = $("#photo").offset();   offset.top -= 10;   $("#photo").offset(offset); });

In addition to the size of HTML elements, you often need to determine their position. There are two different types of positions when working with HTML elements. The first type is the position relative to the full document. The second type is the position relative to the HTML element that acts as an offset parent. The element that is the offset parent depends on the position settings in CSS.

jQuery provides the .position([position]) method to get the position relative to the offset parent. The .offset([position]) method provides the position relative to the document. ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.