Output tag and coordinates : offset « jQuery « JavaScript DHTML






Output tag and coordinates

    
<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("*", document.body).click(function (e) {
                  var offset = $(this).offset();
                  e.stopPropagation();
                  alert(this.tagName + " coords ( " + offset.left + ", " +
                                                  offset.top + " )");
           });


        });
    </script>
  </head>
  <body>
    <body>
      
       <b>Hello asdf asdf</b>
    </body>
</html>

   
    
    
    
  








Related examples in the same category

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