14 August 2019

How To Create a Scroll To Top Button in php?

 Create a Scroll To Top Button



<html>
<head>



<script>
// 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 >500|| document.documentElement.scrollTop >500) {
    document.getElementById("myBtn").style.display = "block";
  } else {
    document.getElementById("myBtn").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>
<style>

#myBtn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 30px;
  z-index: 99;
  font-size: 18px;
  border: none;
  outline: none;
  background-color:#EAC159;
  color: white;
  cursor: pointer;
  padding: 15px;
  border-radius:50%;
  opacity: 0.5;
}

#myBtn:hover {
  background-color: #555;
}
.red{
color:red;
}



</style>
<head>
<body>

<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>



<h1 class="red" >hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>

<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
</body>

</html>

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...