How To Create a Scroll To Top Button

You can scroll the page to the top by adding the buttons in the web page.

To do this, a script function we will use will be sufficient.

With the data-target feature, we can set where the page will scroll.

 

	<div class="scroll-to-target" data-target="html"></div>

 

We connect it to the script with scroll-to-target or any class you specify.

 

	if($('.scroll-to-target').length){
		$(".scroll-to-target").on('click', function() {
			var target = $(this).attr('data-target');
		   // animate
		   $('html, body').animate({
			   scrollTop: $(target).offset().top
			 }, 1500);
	
		});
	}

0 Yorum

Soru & Yorum


Web Tasarım

Renkli Kare

Web Tasarım Ajansı