jQuery animation special effects example tutorial_jquery
This article describes in detail the implementation method of jQuery animation special effects in the form of examples. Share it with everyone for your reference. The specific method is as follows:
1. Customized foldable content block
The content block is as follows:
<div class="module"> <div class="caption"> <span>标题</span> <img src="rollup.gif" alt="rollup" title="rolls up this module"/> </div> <div class="body"> 近日,《体坛周报》记者马德兴在接受天津体育频道《体坛新视野》节目采访时表示自己对恒大[微博]的情况比较担忧,恒大统治力比上赛季下降了很多,恒大外援存在位置重叠的问题,客场不输给西悉尼流浪者就是一个可以接受的结果。该节目称恒大联赛3连胜胜之不武,恒大的惹不起不过尔尔,恒大失去了对其它球队压倒性的优势,能力下降是恒大霸主地位有所动摇的根源所在。 </div> </div>
Bind a click event to the img element.
$(function() { $('div.caption img').click(function () { //先找到img的父级元素,再找该父级元素的子元素 var $body = $(this).closest('div.module').find('div.body'); if ($body.is(':hidden')) { $body.show(); } else { $body.hide(); } }); });
The operation effect is as shown below:
To switch the display state of an element, you can also use the toggle method.
$(function() { $('div.caption img').click(function () { $(this).closest('div.module').find('div.body').toggle(); }); });
The above does not have animation effects, and sometimes it feels very abrupt. In fact, the show, hide, and toggle methods can all have animation effects. For example:
$(function() { $('div.caption img').click(function () { $(this).closest('div.module').find('div.body').toggle('slow'); }); });
Another example:
$(function() { $('div.caption img').click(function () { $(this).closest('div.module').find('div.body').toggle('slow', function() { $(this).closest('div.module').toggleClass('rolledup', $(this).is(':hidden')) }); }); });
2. Make elements fade in and out
fadeIn(speed, callback) fadeOut(speed, callback) fadeTo(speed, opacity, callback)
3. Slide the element up and down
slideDown(speed, callback) slideUp(speed, callback) slideToggle(speed, callback)
4. Stop animation
stop(clearQueue, gotoEnd)
5. Create custom animations
animate(properties, duration, easing, callback) $('.classname').animate({opacity:'toggle'},'slow')
If you write an extension function.
$.fn.fadeToggle = function(speed){ return this.animate({opacity:'toggle'},'slow'); }
6. Customize zoom animation
$('.classname').each(function(){ $(this).animate({ width: $(this).width() * 2, height: $(this).height() * 2 }); });
7. Customize falling animation
$('.classname').each(function(){ $(this) .css("position","relative") .animate({ opacity: 0, top: $(window).height() - $(this).height() - $(this).position().top },'slow',function(){ $(this).hide(); }) });
8. Customized dissipation animation
$('.classname').each(function(){ var position = $(this).position(); $(this) .css({ position: 'absolute', top: position.top, left:position.left }) .animate({ opacity: 'hide', width: $(this).width()*5, height: $(this).height()*5 top: position.top - ($(this).height() * 5 / 2), left: position.left - ($(this).width() * 5 /2) },'normal'); });
9. Animation in queue
//动画插入队列 $('img').queue('chain', function(){}); $('img').queue('chain', function(){}); $('img').queue('chain', function(){}); $('img').queue('chain', function(){}); $('button').click(function(){ $('img').dequeue('chain'); //删除队列中的动画 }) cleaeQueue(name)//删除所有未执行的队列中的动画 delay(duration, name)//为队列中所有未执行的动画添加延迟
I believe that what is described in this article has certain reference value for everyone’s jQuery programming.

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

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)

Hot Topics











We often use ppt in our daily work, so are you familiar with every operating function in ppt? For example: How to set animation effects in ppt, how to set switching effects, and what is the effect duration of each animation? Can each slide play automatically, enter and then exit the ppt animation, etc. In this issue, I will first share with you the specific steps of entering and then exiting the ppt animation. It is below. Friends, come and take a look. Look! 1. First, we open ppt on the computer, click outside the text box to select the text box (as shown in the red circle in the figure below). 2. Then, click [Animation] in the menu bar and select the [Erase] effect (as shown in the red circle in the figure). 3. Next, click [

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

Sometimes we encounter the need to add animation to a ppt. For example, if we want to make a thunderstorm ppt and add some animated thunderstorm effects to it, what should we do? Today, the editor will introduce to you how to make an animated thunderstorm in thunderstorm ppt. It is actually very simple, come and learn it! 1. First we open a PPT page, "Insert" - "Shape" - "Basic Shape" - "Lightning Shape", as shown in the picture. 2. In the "Fill and Line" tab on the right, select "Fill": white; "Select" "Line": black, as shown in the figure. 3. Click "Animation" - "Custom Animation" - "Add Effects" - "Emphasis" - "Subtle" - "Flickering",

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:
