scrolleventjavascript2
<html>
<head>
<title>facebook.com</title>
</head>
<style>
div{
background-color: green;
width: 200px;
height: 200px;
display: none;
}
body{
height: 2000px;
}
</style>
<body>
<div id='a'>
</div>
<script>
window.addEventListener('wheel',function(e){
if(e.deltaY<0)//scrolling up
{
console.log("scrolling up");
}
if(e.deltaY>0)//scrolling down
{
console.log("scroll down");
}
})
</script>
</body>
</html>
Comments
Post a Comment