Zack Sac S Zack Sac S - 1 year ago 83
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download