Zack Sac S Zack Sac S - 2 months ago 11
jQuery Question

Get the position from top of current window

Is there any way to get bottom position using jquery of current viewport while scrolling . Not the bottom position of document but bottom position of visible window.


You need to sum window's scrollTop and innerHeight properties. It may be done this way:

var win = $(window);
var info = $('.bottom-position');
function onScroll() {
    var viewportBottom = win.scrollTop() + win.innerHeight();
    info.html('Bottom viewport at: ' + viewportBottom + 'px from top.');
win.on('scroll resize', onScroll);
body {
    margin: 0;
    font-family: sans-serif;
.content {
    height: 1000px;
    background: #000;
.bottom-position {
    position: fixed;
    bottom: 0;
    right: 0;
    color: #fff;
<script src=""></script>
<div class="content"></div>
<div class="bottom-position"></div>

Also on JSFiddle.