Search This Blog

Monday, March 18, 2019

How to scroll up the page using jquery

Welcome to  designer dairy blog, here we are going to  discuss how to scroll up the page using jquery.

Step1:

In my scenario, I have the fixed header and the content area consists of the anchor tag link. when the user clicks the link it should be moved to appropriate section.

Step2:



Script:


<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>

<script>

$(function(){

$('a[href^="#"]').not('[href=#]').click(function(e){

var anchorTag=$(this).attr('href').replace('.','\\.');

$('html, body').animate({scrollTop: $(anchorTag).offset().top - ($('.searchbar').outerHeight()+5) }, 1000);

return false

;

}

);

Step3:

Thanks for reading my article.Stay Tune on www.webdesignersdairy.com  for more updates on Jquery.

No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...