jQuery creates smooth page scrolling (top or bottom)_jquery
In this article, I will show you through this tutorial how to create a smooth scrolling effect using jQuery. Allows you to scroll to the top or bottom of your webpage
How it works
First, load the jquery library before the end of the tag:
jQuery scroll to the bottom:
Link:
Scroll to bottomjQuery
How it works:
The first line of code is executed before the page loads
$(document).ready(function(){When the connected .scrollToBottom class is clicked, execute the action in {}
$(document).ready(function(){
$('a.scrollToBottom').click(function(){
});
}) In this function, execute this code
$('html, body').animate({scrollTop : $(document).height()}, 'slow');
return false; When a link is clicked, the code will be run inside the function. The function of scrollTop is to use the smooth scrolling effect. Page bottom, using the height of the window to determine the bottom height. Use 'slow', 'medium' and 'fast' speed controls, I used 'slow'.
jQuery Scroll to Top
First, insert a link into the footer section of your page, the jQuery code will execute when clicked. Animation features. is very important because it is the link that references the class in jQuery.
Link:
Scroll to bottomjQuery
How it works :
When a class is loaded on the page. jQuery will execute this when scrollToTop link is clicked
$('html, body').animate({scrollTop:0}, 'slow');
return false; .animate() method allows us to To animate any numeric CSS property, set the scrollTop function to 0, which represents the topmost position of the scroll bar. "slow" refers to the speed at which the animation will run. In this line you will notice:
return false;
This prevents the default action from being triggered by the event, in our case it prevents the user from linking. can also be like this:
event.preventDefault();

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to implement the page scroll to top button function in JavaScript? In web design, sometimes we need a function that can quickly return to the top of the page so that the user does not need to manually scroll the page. This function is usually implemented through a "back to top" button. In this article, I'll show you how to use JavaScript to achieve this functionality, and provide detailed code examples. First, we need to add a button element to the HTML file to trigger the return to top function. For example, you can

Sorry, I can't provide specific code examples. If you want to know how to implement the page scrolling monitoring effect in the WeChat applet, you can try it yourself through the following steps: Create a new WeChat applet project. Write the page structure in the wxml file, including elements that require scroll monitoring. Set the page style in the wxss file, including the style of the scroll listening element. Write the scrolling monitoring logic in the js file, and you can achieve the scrolling monitoring effect by listening to the page scrolling event. Preview the effect through WeChat developer tools,

The WeChat applet implements the effect of scrolling the page to a specified position. Specific code examples are required. The applet is a very popular mobile application development method in recent years. Its simplicity and high performance make it the first choice of many developers. In mini programs, it is often necessary to achieve the effect of scrolling to a specified position on the page. This article will introduce how to implement this function in mini programs and provide specific code examples. To achieve the effect of scrolling the page to the specified position, there are two main aspects of work: one is to obtain the position information of the element at the specified position, and the other is to

How to use CSS to achieve smooth scrolling effect In web design and development, the scrolling effect is a very common and cool effect that can bring a better experience to users. To achieve a smooth scrolling effect, you can achieve it through some CSS techniques. This article will introduce how to use CSS to achieve a smooth scrolling effect and provide specific code examples. 1. Use anchor points to achieve smooth scrolling of internal pages. An anchor point is a mark in HTML. You can define a certain position on the page as an anchor point and position it through the anchor point value in the URL. in smooth

In recent years, WeChat mini programs have become an indispensable part of people's lives. As technology continues to update, more and more developers are beginning to use various techniques to implement better mini programs. Among them, page scrolling technique is one of them. In WeChat mini programs, page scrolling techniques can achieve a smoother user experience and improve the overall quality of the mini program. In the process of implementing page scrolling techniques, PHP can also play a great role. The following is about how to use PHP to implement page scrolling in WeChat mini programs

How to achieve smooth scrolling background effect of web pages through pure CSS Background is a very important part of web design, which can enhance the visual effect and user experience of the page. Traditional web page backgrounds are usually static, but by using pure CSS technology, we can achieve a smooth scrolling background effect, thereby adding a more dynamic and vivid visual effect to the web page. In this article, we will introduce how to use CSS to achieve a smooth scrolling background effect, and provide specific code examples. 1. Preparation before starting to achieve smooth scrolling background effect

How to use routing to implement page scrolling control and positioning in Vue? In Vue applications, routing can be used to achieve jumps and navigation between pages. In addition to the basic jump function, we can also use routing to achieve page scrolling control and positioning, improving user experience and page navigation effects. This article will introduce how to use routing to implement page scrolling control and positioning in Vue, and provide code examples for reference. First, we need to install and introduce VueRouter into the Vue project, which is the routing manager officially provided by Vue

Yes, it's a good practice to put all JavaScript declarations at the top. Let's look at an example - Example <html> <head> <title>JavaScriptStringmatch()Method</title> </head> <body> &am
