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

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -