Read & lt; jquery authoritative guide & gt; [3]-Animation

Source: Internet
Author: User

1. Method:

  • Hide (speed, [callback]);
  • Show (speed, [callback]);

Note: These two methods can also be used to hide and show animations. Speed can be "slow" (600 ms), "normal" (400 ms), "fast" (200 ms), or a number of milliseconds.

Callback is the callback function after the animation is executed.

2. instance:

> ---: -- Height: </style> <div => <span> & nbsp; </span> <span> jQuery </span> <span style => -- write less, more. </span> & nbsp; <a href => display </a> </div>Html
<Script type = "text/javascript"> $ link = $ (". artList a "$ hide = $ (". artList: eq (2) "($().html () =" show ").html (" hide "1000, () {alert (" show ").html (" show "800 ,() {alert ("hide" </script>

1. Method

  • Toggle (): No parameter. You can directly switch to the hidden state;
  • Toggle (switch): The switch is a Boolean value. true indicates the display element, and false indicates the hidden element.
  • Toggle (speed, [callback]): speed indicates the switching speed, and callback indicates the callback function after the animation effect is executed.

Note: When an animation is displayed, the width, height, padding, and margin of the element are displayed in the animation format.

2. instance:

==>< Div => <input id = type = value =/> <br/> <input id = type = value =/> </div> <div => </div>Html
<Script type = "text/javascript"> isShow = title = $ (". divTitle "content = $ (". divContent "" img "). slideUp ("normal", "# divTip" ).html ("disabled successfully" = "img "). slideDown ("normal" "# divTip" pai.html ("" = </script>
  • SlideUp (speed, [callback]): slides up to reduce the element height to 0
  • SlideDow (speed, [callback]): slides down to increase the element height.
  • SlideToggle (speed, [callback]): switches the element height with an animation effect.

1. Fade-in and fade-out methods

  • FadeIn (speed, [callback]): fade in, transparency from 0.0 to 1.0;
  • FadeOut (speed, [callback]): fade out, transparency from 1.0 to 0.0;

Instance:

==>< Div => <input id = type = value =/> </div> <div => </div> </div>Html
<Script type = "text/javascript" >=$ ("img"); $ tip = $ (". divTip "); $ (" # Button1 "). click () {effectip.html (""); $ img. fadeIn (2000, "Fade in successful! "" # Button2 "). click () {effectip.html (" "); $ img. fadeOut (2000," Fade out successful! "</Script>

2. fadeTo(Speed, opacity, [callback]): sets the transparency as a specified value based on the animation effect. You can also set a callback function.

Instance:

Html
<script type="text/javascript"> opacity = 0.0"#btn").click( (opacity >= 1.0= 0.0+= opacity + 0.2"img").fadeTo("normal"</script>

1. Method:

Animate (params, [duration], [easing], [callback])

Note: param indicates the attribute key-value pair to be adjusted, duration indicates the speed, easing indicates the animation plug-in, and callback indicates the callback effect after the animation effect is completed.

Note:

Params attribute names must be written in the form of camels. For example, font-size must be written as fontSize.

If you want to move the element position as an animation, the position must be set to relative or absolute.

Queue Animation: execute one or more animation methods in the element.

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.