Jquery element position

From John Freier
Revision as of 17:09, 5 October 2011 by Jfreier (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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);