Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
64
rated 0 times [  68] [ 4]  / answers: 1 / hits: 194326  / 12 Years ago, wed, may 16, 2012, 12:00:00

I have a web document with scroll. I want to get the value, in pixels, of the current scroll position. When I run the below function it returns the value zero. How can I do this?



<script type=text/javascript src=js/jquery-1.7.2.js></script>
<script type=text/javascript src=js/jquery.mousewheel.min.js></script>
<script type=text/javascript>
$(function (){
$('#Eframe').on(mousewheel, function() {
alert(document.body.scrollDown)
}
})
</script>

More From » jquery

 Answers
43

Since it appears you are using jQuery, here is a jQuery solution.



$(function() {
$('#Eframe').on(mousewheel, function() {
alert($(document).scrollTop());
});
});


Not much to explain here. If you want, here is the jQuery documentation.


[#85547] Tuesday, May 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kourtney

Total Points: 368
Total Questions: 103
Total Answers: 85

Location: Bonaire
Member since Sat, May 1, 2021
3 Years ago
kourtney questions
Sun, Oct 4, 20, 00:00, 4 Years ago
Tue, Oct 29, 19, 00:00, 5 Years ago
Thu, Apr 4, 19, 00:00, 5 Years ago
Fri, Mar 1, 19, 00:00, 5 Years ago
;