offset(): returned object contains two Integer properties, top and left. (works only with visible elements) : offset « jQuery « JavaScript DHTML






offset(): returned object contains two Integer properties, top and left. (works only with visible elements)

 



<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
        
            var p = $("p:last");
            var offset = p.offset();
            p.html( "left: " + offset.left + ", top: " + offset.top );
            

        });
    </script>

  </head>
  <body>
    <body>
         <p>Hello</p><p>2nd Paragraph</p>
                 
    </body>
</html>

   
  








Related examples in the same category

1.Get offset
2.Get top
3.Output tag and coordinates