Hiệu tứng scroll cực chất (ok)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<style>
#wrap {
width: 100%;
height: 1000px;
}
#btn-top {
display: none;
background-color: red;
width: 50px;
height: 50px;
position: fixed;
right: 10px;
bottom: 10px;
}
</style>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>
jQuery(window).scroll(function(){
if(jQuery(this).scrollTop()>300){
jQuery('#btn-top').fadeIn('slow');
}else{
jQuery('#btn-top').fadeOut('slow');
}
});
</script>
<body>
<div id="wrap">
<div id="btn-top"></div>
</div>
</body>
</html>
Last updated