Get bottom and right position of an element

后端 未结 7 867
遇见更好的自我
遇见更好的自我 2020-12-01 00:45

I\'m trying to get the position of an element within the window like so:

var link = $(element);

var offset = link.offset();
var top = offset.top;
var left =         


        
7条回答
  •  北海茫月
    2020-12-01 01:10

    I think

    
    
    
    Testing

    The result are

    top: 44
    bottom: 544
    left: 72
    right: 1277
    bottomFromBottom: 3068
    rightFromRight: 3731
    

    in chrome browser of mine.

    When the document is scrollable, $(window).height() returns height of browser viewport, not the width of document of which some parts are hiden in scroll. See http://api.jquery.com/height/ .

提交回复
热议问题