How To Create a Scroll Back To Top Button using jQuery

How To Create a Scroll Back To Top Button using jquery

In today’s web design landscape, creating a smooth and user-friendly experience is crucial for engaging your website visitors. One effective way to enhance user navigation is by implementing a “Scroll Back to Top” button. This handy feature allows users to effortlessly return to the top of a webpage with a single click, saving them from endless scrolling.

In this tutorial, we will explore How to create a Scroll Back to Top button using jQuery, a popular JavaScript library. By the end, you will have the knowledge to add this valuable functionality to your own website and provide an enhanced user experience. So let’s dive in and get started!

How To Build Scroll Back To Top Only with HTML?

<div class="cxc-main-warap">  
		<div class="cxc-back-to-top">
			<a class="cxc-back-to-top-btn" href="javascript:;"><i class="fa fa-angle-up" aria-hidden="true"></i></a>

How To Build Scroll Back To Top only with CSS?

<style type="text/css">
		.cxc-main-warap .cxc-back-to-top .cxc-back-to-top-btn {
			display: inline-block;
			background-color: #587052;
			width: 50px;
			height: 50px;
			text-align: center;
			border-radius: 4px;
			position: fixed;
			bottom: 30px;
			right: 30px;
			transition: background-color .3s, opacity .5s, visibility .5s;
			opacity: 0;
			visibility: hidden;
			z-index: 1000;
		.cxc-main-warap .cxc-back-to-top .cxc-back-to-top-btn i {
			line-height: 50px;
			color: #fff;
		.cxc-main-warap .cxc-back-to-top .cxc-back-to-top-btn:hover {
			cursor: pointer;
			background-color: #ffbc66;
			transition: .5s;
		.cxc-main-warap .cxc-back-to-top .cxc-back-to-top-btn:hover i{
			color: #000;
		.cxc-main-warap .cxc-back-to-top .cxc-back-to-top-btn:active {
			background-color: #555;
		.cxc-main-warap .cxc-back-to-top {
			opacity: 1;
			visibility: visible;
			-webkit-transform: translateY(0);
			-ms-transform: translateY(0);
			transform: translateY(0);
			animation: bounceInDown 2s;
			-webkit-animation: bounceInDown 2s;
			-moz-animation: bounceInDown 2s;

		@keyframes bounceInDown {

			to {
				animation-timing-function: cubic-bezier(.215, .61, .355, 1)

			0% {
				opacity: 0;
				transform: translate3d(0, -3000px, 0)

			60% {
				opacity: 1;
				transform: translate3d(0, 25px, 0)

			75% {
				transform: translate3d(0, -10px, 0)

			90% {
				transform: translate3d(0, 5px, 0)

			to {
				transform: none

How To Build Scroll Back To Top only with JQuery?

<script type="text/javascript">

		jQuery(document).ready( function() {

			jQuery(window).scroll(function() {
				if (jQuery(window).scrollTop() > 200) {
				} else {

			jQuery(document).on('click', '.cxc-back-to-top-btn', function(e) {
				jQuery('html, body').animate({scrollTop:0}, '200');



Do I need any prior coding experience to implement a Scroll Back to the Top button?

Basic knowledge of HTML, CSS, and JavaScript will be helpful for understanding the concepts involved. However, this tutorial will provide step-by-step instructions, making it accessible even for beginners.

Can I customize the appearance of the Scroll Back to Top button?

Absolutely! You can easily customize the button’s appearance using CSS. tutorial on CodexCoach will cover the basic implementation, but you can modify the styles to match your website’s design.

Can I implement the Scroll Back to Top button on specific pages of my website?

Yes, you can choose to include the Scroll Back to Top button on specific pages or templates of your website. This allows you to tailor the functionality according to your needs.

Can I add additional animations or effects to the Scroll Back to Top button?

Certainly! You can enhance the Scroll Back to Top button with various animations and effects using jQuery or CSS. This tutorial will focus on the basic functionality, but you can explore additional enhancements to make it visually appealing.

How useful was this blog?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this blog.

Leave a comment

Your email address will not be published. Required fields are marked *