Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var offset = $("selector").offset();
- offset.top // Top position, relative to the top of the page
- offset.left // Left position, relative to the left of the page
- var absolute_coordinates = $('#mydiv').offset(); // top and left with respect to document
- var relative_coordinates = $('#mydiv').position(); //top and left with respect to parent
- alert('#mydiv is ' + relative_coordinates.top
- + 'px below from parent and absolute_coordinates.top +
- 'px below from document');
- $(".divItem").click(function(){
- alert("Left is : "+$(this).offset().left)
- });
Advertisement
Add Comment
Please, Sign In to add comment