When a css file contains an instruction like this:
body {
width: 100%;
height: 100%;
}
A JS code like the following does not detect the scrolling event.
$(window).on('scroll', function(){
alert('this alert does not fire');
});
I guess with that css, there is no possibility of a scroll event and hence the reason why the scrolling event does not fire.
So I wrapped the entire page body content into a div, like this:
<body>
<div canvas="container">
the entire page content here
</div>
</body>
In this case, what would be the correct version of the JS code below so we can catch these alerts in a timely fashion?
$(window).on('scroll', function(){
if( $(window).scrollTop()>50 ){
alert('1');
}
else {
alert('2');
}
});