JQuery animation and special effect instance analysis, and jquery special effect instance analysis
This article analyzes the usage of JQuery animation and special effects. Share it with you for your reference. The specific analysis is as follows:
Show and hide
Show (spped, [callback]) and hide (spped, [callback])
The speed options include slow, normal, and fast. The corresponding speed is 600 ms, 400 ms, and 200 ms respectively. You can also enter the number of milliseconds. The callback function is the callback function, which is called after the action is completed.
$("img").show(3000,function(){ $(this).css("border","solid 1px #ccc”); });
Toggle () function, no parameter format, switching between display and hide
Toggle (true orfalse) is in the Boolean format. If it is true, the element is displayed. Otherwise, the element is hidden.
Toggle (speed, [callback]) is similar to the show () function.
Slide
SlideDown (spped, [callback]) and slideUp (spped, [callback])
Essentially, it changes the height of an element.
SlideToglge (spped, [callback]) Switch slide Effect
Fade in and out
FadeIn (spped, [callback]) and fadeOut (spped, [callback])
Essentially, it changes the transparency of elements.
FadeTo (spped, opacity, [callback]); opacity is transparency, between 0 and 1, and 1 is completely transparent
Custom Animation
Animate (params, [duration], [easing], [callback])
Params indicates the attribute styles and worthy sets used to make the animation effect.
Duration indicates three default speed characters, slow, normal, fast, or custom millisecond count
Easing is used as an animation plug-in to control the animation performance. It usually has linear and swing character values.
Callback Function executed after the callback is completed
$ (This ). animate ({width: "20%", height: "70px"}, // Object Notation, which is commonly used in JQuery to pass Parameters 3000, function () {detail (this).css ("border ": "solid 3px #666 "). html ("Bigger !! ") ;}); // When passing parameters, you must use the camel method to write the attribute name. For example, font-size must be written as fontSize.
$ ("P"). animate ({left: "20px", top: "70px"}, 3000) // move 20 pixels to the right and 70 pixels down
Stop ([clearQueue], [gotoEnd])
ClearQueue is a Boolean value indicating whether to stop an animation being executed.
GotoEnd is a Boolean value that indicates whether an animation is being executed immediately.
Delay (duration, [queueName])
Duration is the delay time value.
QueueName indicates the queue term, that is, the animation queue.
$ ("A: eq (0 )"). click (function () {$ ("img "). slideToggle (3000) ;}); // change the image by using the "curtain pulling" method $ ("a: eq (1 )"). click (function () {$ ("img "). stop () ;}); // stop an animation in progress $ ("a: eq (2 )"). click (function () {$ ("img "). delay( 2000 ). slideToggle (3000) ;}); // delay switching Image
I hope this article will help you with jQuery programming.