Guest User

Untitled

a guest
May 23rd, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. var offset = $("selector").offset();
  2. offset.top // Top position, relative to the top of the page
  3. offset.left // Left position, relative to the left of the page
  4.  
  5. var absolute_coordinates = $('#mydiv').offset(); // top and left with respect to document
  6.  
  7. var relative_coordinates = $('#mydiv').position(); //top and left with respect to parent
  8.  
  9. alert('#mydiv is ' + relative_coordinates.top
  10. + 'px below from parent and absolute_coordinates.top +
  11. 'px below from document');
  12.  
  13. $(".divItem").click(function(){
  14. alert("Left is : "+$(this).offset().left)
  15. });
Advertisement
Add Comment
Please, Sign In to add comment