Header Ads






Scrooll Up Button


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Index</title>
</head>
<body>
   
      <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 20px;
}
#myBtn {
  position: fixed;
  padding: 15px;
  right: 10px;
  bottom: 10px;
  background-color: red;
  font-size: 30px;
  border: solid;
  border-radius: 50px;
}
</style>
<button onclick="topFunction()" id="myBtn" title="Go to top">🕋</button>


<div style="background-color:blue;color:white;padding:10px">Tohin</div>
<div style="background-color:lightblue; padding:30px 30px 2500px">Tania
  <strong>Raj</strong> Munna</div>


<script>
//Get the button
var mybutton = document.getElementById("myBtn");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
    mybutton.style.display = "block";
  } else {
    mybutton.style.display = "none";
  }
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
  document.body.scrollTop = 0;
  document.documentElement.scrollTop = 0;
}
</script>
   
</body>
</html>

No comments

Powered by Blogger.