jquery - Get the position from top of current window -


is there way bottom position using jquery of current viewport while scrolling . not bottom position of document bottom position of visible window.

you need sum window's scrolltop , innerheight properties. may done way:

var win = $(window);  var info = $('.bottom-position');  function onscroll() {      var viewportbottom = win.scrolltop() + win.innerheight();      info.html('bottom viewport at: ' + viewportbottom + 'px top.');  };  win.on('scroll resize', onscroll);  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="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class="content"></div>  <div class="bottom-position"></div>

also on jsfiddle.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -