What are the jquery animation functions?
There are 17 types of jquery animation functions: 1. animate(), used to apply custom animations to selected elements; 2. hide(), used to hide selected elements; 3. show(), Used to display selected elements; 4. fadeOut(), used to hide elements by setting opacity; 5. fadeTo() and so on.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
jquery animation functions
The table below lists all the jQuery methods used to create animation effects.
Method | Description |
---|---|
animate() | Apply to the selected elements" Customized "animation |
clearQueue() | Remove all queued functions (not yet running) from the selected elements |
delay() | Set a delay for all queued functions (not yet run) of the selected elements |
dequeue() | Remove Next queue the function, and then execute the function |
fadeIn() | Gradually change the opacity of the selected element from hidden to visible |
fadeOut() | Gradually change the opacity of the selected element, from visible to hidden |
fadeTo() | Fade the selected element The element gradually changes to the given opacity |
fadeToggle() | Toggle between fadeIn() and fadeOut() methods |
finish() | Stop, remove and complete all queued animations for the selected element |
hide() | Hide is Select element |
queue() | Show the queue function of the selected element |
show() | Display the selected element |
slideDown() | Slide and display the selected element by adjusting the height |
slideToggle() | Switching between slideUp() and slideDown() methods |
slideUp() | Slide and hide the selected element by adjusting the height |
stop() | Stop the currently running animation on the selected element |
toggle() | Switching between hide() and show() methods |
Here are some commonly used animation functions.
1. animate()
The animate() method performs custom animations of CSS property sets.
This method changes an element from one state to another through CSS styles. CSS property values change gradually, allowing you to create animated effects.
Only numeric values can be animated (such as "margin:30px"). String values cannot be animated (such as "background-color:red").
Tip: Please use " =" or "-=" to create relative animations.
Example: Apply animation to an element by changing its height:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("#btn1").click(function() { $("#box").animate({ height: "300px" }); }); $("#btn2").click(function() { $("#box").animate({ height: "100px" }); }); }); </script> </head> <body> <button id="btn1">使用动画放大高度</button> <button id="btn2">重置高度</button> <div id="box" style="background:#98bf21;height:100px;width:100px;margin:6px;"> </div> </body> </html>
##2, hide(), show() and toggle( )
- hide() method hides the selected elements.
- show() displays the selected element
- toggle(): switch between hide() and show() methods
element
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $(".btn1").click(function() { $("p").hide(); }); $(".btn2").click(function() { $("p").show(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button class="btn1">隐藏</button> <button class="btn2">显示</button> </body> </html> </html>
3, slideUp(), slideDown() And slideToggle()
- slideUp() method: Hide the selected element in a sliding manner.
- slideDown() method: Display the selected element in a sliding manner.
- slideToggle() method: switching between slideUp() and slideDown() methods
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script ></script> <script> $(document).ready(function() { $(".btn1").click(function() { $("p").slideUp(); }); $(".btn2").click(function() { $("p").slideDown(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button class="btn1">上滑</button> <button class="btn2">下滑</button> </body> </html>
4, fadeIn(), fadeOut() and fadeToggle()
- fadeIn () method gradually changes the opacity of the selected element from hidden to visible (fading effect).
- fadeOut() method gradually changes the opacity of the selected element from visible to hidden (fade effect).
- fadeToggle(): Switch between fadeIn() and fadeOut() methods
Element
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $(".btn1").click(function() { $("p").fadeOut() }); $(".btn2").click(function() { $("p").fadeIn(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button class="btn1">淡出</button> <button class="btn2">淡入</button> </body> </html>
5, fadeTo()
fadeTo() method gradually changes the opacity of the selected element to the specified value (faded effect).<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { $("p").fadeTo(1000, 0.4); }); }); </script> </head> <body> <button>逐渐改变P元素的不透明度</button> <p>这是一个段落。</p> </body> </html>
jQuery video tutorial, web front-end video 】
The above is the detailed content of What are the jquery animation functions?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

jQuery is a popular JavaScript library widely used in web development. During web development, it is often necessary to dynamically add new rows to tables through JavaScript. This article will introduce how to use jQuery to add new rows to a table, and provide specific code examples. First, we need to introduce the jQuery library into the HTML page. The jQuery library can be introduced in the tag through the following code:

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute
