Scroll to the top of page using jQuery JavaScript


Scroll to the top of page using jQuery JavaScript – There are many ways to scroll top of the screen. You can use javascript or jquery to scroll top of the page. Here in this tutorial we are going to explain how you can scroll to the top of page using javascript and jquery both. We will explain this example and demo.


Scroll to the top of page using jQuery JavaScript

You can scroll to the top using jquery or javascript both. Let us go one by one.

Using JavaScript :

Using JavaScript you can scroll top simply as –

Scroll to the top of page using jQuery JavaScript Example:

<script type="text/javascript">
function scrollToTop(){
window.location = '#';
}
</script>

Try it »

If you run the above example it will produce the following output-

Using jQuery:

You can also scroll top using jQuery also –

Scroll to the top of page using jQuery JavaScript Example:

<script type="text/javascript">
function scrollToTop(){
$(window).scrollTop(0);
}
</script>

Try it »

If you run the above example it will produce the following output –

Scroll to the top of page using jQuery JavaScript


Advertisements

Add Comment

📖 Read More