<script> $(document).ready(function(){ $(window).scroll(function(){ if ($(this).scrollTop() >= 100) { alert("100!"); } }); }); </script> Why when I scroll the page does the alert not work?
<script> $(document).ready(function(){ $(window).scroll(function(){ if ($(this).scrollTop() >= 100) { alert("100!"); } }); }); </script> Why when I scroll the page does the alert not work?
Explicitly refer to window:
$(document).ready(function() { $(window).scroll(function() { console.log($(window).scrollTop()); if ($(window).scrollTop() >= 100) { alert("100!"); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br> 1<br>1<br> Source: https://ru.stackoverflow.com/questions/581812/
All Articles
<body>, something withoverflow:autooroverflow:scrollscrolls inside? - Surfin Bird