What are the jquery effects

Source: Internet
Author: User

Jqeury's effects include hidden display, fade, swipe, animate, stop animation, and link methods and actions. Let me take a look at their usage and required parameters.

1. Hide/Show

Hide () causes the element to be hidden. The syntax is: $ (selector). Hide (Speed,callback);

Show () causes the element to be displayed. The syntax is: $ (selector). Show (Speed,callback);

Toggle () Toggles the Hide () and show () methods. The syntax is $ (selector). Toggle (Speed,callback);

The optional speed parameter specifies the rate of concealment/display, which can take the following values: "Slow", "fast", or milliseconds.

The optional callback parameter is the name of the function that is executed after the animation is completed.

2. Fade In/Fade out
FadeIn () is used to fade in hidden elements. Syntax: $ (selector). FadeIn (Speed,callback);

FadeOut () is used to fade in hidden elements. Syntax: $ (selector). FadeOut (Speed,callback);

the Fadetoggle () method can be toggled between the fadeIn () and the FadeOut () method. Syntax:$ (selector). Fadetoggle (speed,callback);

If the element has faded out, fadetoggle () adds a fade effect to the element.

If the element has been faded in, fadetoggle () adds a fade effect to the element.

the FadeTo () method allows the gradient to be given transparency (values between 0 and 1). Syntax:$ (selector). FadeTo (speed,opacity,callback);

The optional speed parameter specifies the length of the effect. It can take the following values: "Slow", "fast", or milliseconds.

The optional callback parameter is the name of the function that is executed after the animation is completed.

The required opacity parameter in the FadeTo () method sets the fade effect to the given opacity (values between 0 and 1).

3. Slide

The Slidedown () method is used to slide the element down. Syntax:$ (selector). Slidedown (speed,callback);

The   slideup () method is used to slide the element up. Syntax:$ (selector). Slideup (speed,callback);
  The Slidetoggle () method can be toggled between the Slidedown () and the Slideup () method.

If the elements slide down, slidetoggle () can slide them up.

If the elements slide up, slidetoggle () can slide them down. Syntax $ (selector). Slidetoggle (speed,callback);

The optional speed parameter specifies the length of the effect. It can take the following values: "Slow", "fast", or milliseconds.

The optional callback parameter is the name of the function that is executed after the slide is completed.

4.animate method

The animate () method is used to create custom animations. Syntax:$ (selector). Animate ({params},speed,callback);

The required params parameter defines the CSS property that forms the animation.

The optional speed parameter specifies the length of the effect. It can take the following values: "Slow", "fast", or milliseconds.

The optional callback parameter is the name of the function that is executed after the animation is completed.

The following example shows a simple application of the animate () method, which moves the <div> element to the left until it is equal to 250 pixels:

     $ ("button"). Click (function () {       $ ("div"). Animate ({left: ' 250px '});     

You can also use multiple properties during animation generation:

     $ ("button"). Click (function () {       $ ("div"). Animate ({left        : ' 250px ',        opacity: ' 0.5 ',        height: ' 150px ',        width: ' 150px '       });     
    Note that by default, all HTML elements have a static location and cannot be moved.

To operate the location, remember to first set the element's CSS position property to relative, fixed, or absolute!

5.stop method

The Stop () method is used to stop animations or effects before they are complete. The Stop () method applies to all JQuery effect functions, including sliding, fading, and custom animations.
    Syntax:$ (selector). Stop (stopall,gotoend);

The optional StopAll parameter specifies whether the animation queue should be cleared. The default is false, which stops only active animations, allowing any queued animation to be executed backwards.

The optional gotoend parameter specifies whether to complete the current animation immediately. The default is False.

6.callback function

When animation 100% is complete, the Callback function is called. The above methods are used, there is not much to say.

7.chaining

Chaining allows us to allow multiple jQuery methods (on the same element) in one statement.

The following example links CSS (), Slideup (), and Slidedown () together. The "P1" element first turns red, then slides up, then slides:

    $ ("#p1"). CSS ("Color", "red"). Slideup (+). Slidedown (2000);

This can also be run:

    $ ("#p1"). CSS ("Color", "red"). Slideup (+).       Slidedown (2000);

JQuery will throw away the extra spaces and execute the lines of code as a line of code.

These are some of the ways in which jquery works, such as omissions or irregularities, please note. Thank you.

What are the jquery effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.