jquery - Using scrollTop() to get position but it is also scrolling the page -


having issue when getting page position using scrolltop(). getting position correctly causing underlying page scroll top (see below). have tried 2 ways:

var page_position = $(document).scrolltop(); $('#main-body').prepend(data.image).css('margin-top', page_position + 'px'); 

and:

$('#main-body').prepend(data.image).css('margin-top', $(document).scrolltop() + 'px'); 

what data.image is div along image (large screenshot) returned ajax call. div image positioning correctly mentioned above underlying page scrolling top.

btw, using foundation , jquery came packaged it, tried using jquery-1.11.3.min.js same results.

plain javascript, want:

var page_position = window.pageyoffset || document.documentelement.scrolltop 

Comments

Popular posts from this blog

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -

SQL Server - MyCTE query based on 24 hour period (next day) -