Effects in jQuery
jQuery provides a simple interface to perform different types of amazing effects. JQuery methods allow us to quickly apply common effects with minimal configuration.
This tutorial will cover all the important jQuery methods for creating Visual Effects.
Show and hide elements in jQuery
If you're expecting short commands to show and hide elements in jQuery, you'll be disappointed. It is really simple and easy to ask.show () to display elements in a wrapped set (wrapped / wrapped) and hide () to hide them.
Show syntax ()
The following is a simple syntax for the show method () in jQuery:
[selector]. show( speed, [callback] );
Detailed description of the parameters:
- speed - A string representing one of the three predetermined speeds ("slow", "normal", or "fast") or milliseconds to run the effect (eg 1000).
- callback - this optional parameter represents a function to be executed whenever the effect completes; execute once for each effect.
Syntax hide ()
This is a simple syntax for hide () method in jQuery:
[selector]. hide( speed, [callback] );
Detailed description of the parameters:
- speed - A string representing one of the three predetermined speeds ("slow", "normal", or "fast") or milliseconds to run the effect (eg 1000).
- callback - this optional parameter represents a function to be executed whenever the effect completes; execute once for each effect.
For example
You consider the following HTML file with a small jQuery code:
The jQuery Example
id="hide"type="button"value="Hide"/> id="show"type="button"value="Show"/>
Toggle elements in jQuery
jQuery provides methods to toggle the display status of elements between display and hide. If the element when initializing is displayed, it will be hidden; If it is hidden, it will be displayed.
Syntax
Simple syntax for a toggle () method in jQuery:
[selector]. .toggle([speed][, callback]);
Below is a description of the parameters:
- speed: A string representing one of three predetermined speeds ("slow", "normal", or "fast") or milliseconds to run the effect (eg 1000).
- callback : This optional parameter represents a function to be executed whenever the effect completes; execute once for each effect.
For example
We can create an effect for any element, such as a div element containing an image:
The jQuery Example
JQuery Effect methods
In the previous section, you followed the basics of jQuery Effect. The table below lists all the basic methods for creating different types of effects:
Method Descriptionanimate (params, [duration, easing, callback])
A function to create custom effects.
fadeIn (speed, [callback])
Fade prints all matching elements by adjusting opacity (brightness) and activating an arbitrary callback after completion.
3fadeOut (speed, [callback])
Fade out all matching elements by adjusting opacity to 0, then setting the display to "none" and activating an arbitrary callback after completion.
fadeTo (speed, opacity, callback)
Fade the shading of all matched elements to a given opacity and activate an arbitrary callback after completion.
hide ()
Hide each element in the matched set if they are already displayed.
hide (speed, [callback])
Hide all matching elements using a nice effect and activate an arbitrary callback after completion.
show ()
Displays each element in the set that matches if they are hidden.
show (speed, [callback])
Displays all matching elements by using a nice effect and activating an arbitrary callback after completion.
slideDown (speed, [callback])
Reveal all matching elements by adjusting their height and activating an arbitrary callback after completion.
slideToggle (speed, [callback])
Toggle the visibility of all matching elements by adjusting the height and activating an arbitrary callback after completion.
slideUp (speed, [callback])
Hide all matching elements by adjusting their height and activating an arbitrary callback after completion.
stop ([clearQueue, gotoEnd])
Stop all currently running effects on all defined elements.
toggle ()
Toggle the display of each element in the set of matching elements.
toggle (speed, [callback])
Toggle the display of each element in the set of matched elements by using a nice effect and activating an arbitrary callback after completion.
toggle (switch)
Toggle the display of each element in the matched set based on the middle switch: true is showing all elements, false is hiding all elements.
jQuery.fx.off
Disable all effects.
UI Library-based effects in jQuery
To use these effects, you can either download the latest jQuery UI Library jquery-ui-1.11.4.custom.zip from jQuery UI Library or use Google CDN to use it in the same way as We made for jQuery.
We used Google CDN for jQuery UI by using the following code snippet in the HTML page:
Method DescriptionBlind
Blind away the element or display it by blind printing.
Bounce
Bounce element vertically or horizontally n times.
Clip
Clip on or clip off element, vertically or horizontally.
Drop
Drop away the element or display it by drop in.
Explode
Explode elements into multiple parts.
Fold
Fold the element as part of the paper.
Highlight
Highlight background with given color.
Puff
Scale and fade out effects creating puff effects.
Pulsate
Pulsate the shading of the element several times.
Scale
Shrink or grow an element by a certain percentage.
Shake
Shake the element vertically or horizontally n times.
Size
Put the element to the specified height and width.
Slide
Slide out the element out of the viewport.
transfer
Transform the shape of an element for another element.
According to Tutorialspoint
Previous post: jQuery Ajax
Next article: What is AngularJS?
You should read it
May be interested
- How to Use jQuery on Your Websitejquery is the most popular javascript language by far, used by many popular websites across the internet. however, since it is a library, it is not a part of unaltered javascript. how, then, can you use jquery on your website? the process...
- jQuery Ajaxajax stands for asynchronous javascript and xml and this technology helps us to download data from the server without refreshing the browser.
- Tooltip creation tools are useful for jQuerytooltip is a tool that displays a caption for an image or a piece of text when moving the cursor to that text or image. the following article will list useful tooltip creation tools with jquery!
- Adobe After Effects 2021.22.0 - download Adobe After Effects 2021.22.0 herelike most adobe products, after effects is considered the standard in the video editing arena. whether you're considering the program for personal use or need to edit movies and videos professionally, the program's set of special effects deliver excellent results.
- How to use effects in PowerPointhow to use effects in powerpoint 2016. in slide, there are many objects that need to use effects. however, for each different object, use different effects.
- Top 10 psychological effects that affect human behavior you may not know yetwe've found 10 psychological effects that affect people's behavior every day and you'll understand why you act in one way or another. invite you to consult!
- How to create beautiful effects with Mo.JStoday, the article will look at mo.js, one of the new applications for creating beautiful animations from code. the article will cover a few basic functions, before creating a series of beautiful reaction effects.
- 7 great HTML effects anyone can add to their websiteyou want your website to look great, but lack web development skills? do not despair! you don't need to know css or php to build a favorite website. this article will give you 7 free html effect templates.
- How to create typewriting effects in PowerPointthis article will show you how to create typewriter effects to help the audience focus more on the content of the presentation.
- MS PowerPoint 2007 - Lesson 10: Slide presentation effectsslide animation effects are predefined special effects that you can add to objects on a slide.