Jquery element position

From John Freier
Jump to: navigation, search

This section is all about how to position elements on a page.


Get Position

To get the position, jquery has a method on it with two attributes.

Left

$(this).position().left

Top

$(this).position().top


Set Position

To set the position of an element, you will want to make the position absolute, and then set the css values.

Position Absolute

position:absolute;

Left

$(this).css('left', 100);

Top

$(this).css('top', 100);