I want to trigger a function or loop when onwheel scroll up or scroll down. Please see my snippet.
let demo = document.querySelector('#demo');
let c = 0;
window.onwheel = function() {
c ++;
demo.innerHTML = c;
}
body{
height: 300vh;
}
h1{
position: fixed;
text-align: center;
width: 100vw;
}
<h1 id="demo" > Hello World </h1>
I need when it will scroll up the number should be increment and when scroll down number should be decrements. but it's just increment the number, I need js clear solution. Thanks.