Javascript examples for jQuery Method and Property:offset
Get the distance from the top for an element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(window).load(function(){//from w w w .j av a 2s .c o m $(function() { console.log($('div.foo').offset().top); }); }); </script> </head> <body> <div style="height:50px"> </div> <div class="foo" style="height:50px;width:80px;background-color:#000;"> </div> </body> </html>