scrolleventjavascript3
<html>
<head>
<title>facebook.com</title>
</head>
<style>
div{
background-color: green;
width: 200px;
height: 200px;
display: none;
position: fixed;
bottom: 0px;
right: 0px;
}
body{
height: 2000px;
}
</style>
<body>
<div id='a'>
</div>
<script>
window.addEventListener('scroll',function(e){
if(window.pageYOffset>150)//scrolling down
{
document.getElementById('a').style.display="block";
}
else//scrolling up
{
document.getElementById('a').style.display="none";
}
})
</script>
</body>
</html>
Comments
Post a Comment