The jquery fade element makes it more vivid _jquery

Source: Internet
Author: User

In order to achieve a more vivid effect, you can fade or fade an element, in either case, the transparency of the element is changed over time. jquery provides 3 and fade-related functions:

Fadein () makes a hidden element fade into view. First, the space that the element occupies appears on the page (which may mean that other elements on the page are to be moved), and then the elements become visible gradually. This function has no effect if the element is already visible on the page. If a speed value is not provided, the element fades in (400 milliseconds) using the general setting.

fadeout () hides it by making a visual element fade out of sight like a phantom. If the element is hidden on the page, the function has no effect, as it does with the Fadein () function. If a speed value is not provided, the element fades out at a rate of 400 milliseconds.

Fadetoggle () combines the effects of fading and fading. If the element is currently hidden, it fades into view, and if it is currently visible, the element fades out of view. You can use this function to have a cue box appear on the page or disappear from the page. For example, suppose you have a button that displays the word "instructions" on it. When a visitor clicks the button, a div with a description fades in, and clicking the button again will leave the description out of view. To have the prompt fade in or out every half second, you can write code like this:

$ (' #button '). Click (function () {
$ (' #instructions '). Fadetoggle (+);
}) ;//end Click

Fadeto () works slightly differently than the other two effect functions. It dilutes the image to a certain degree of transparency. For example, you can make the image fade to translucent. Unlike other effects, you must provide a speed value. In addition, a value between 0~1 is provided to represent the transparency of the element. For example, to dilute all paragraphs to 75% transparency, you can write code like this:

$ (' P '). Fadeto (' normal ',. 75);

This function changes the transparency of an element, regardless of whether the element is visible or not. For example, suppose you want to dilute one of the currently hidden elements to 50% transparency. Then, if you use Show () or Fadein () to display the element, it will appear with 50% transparency. Similarly, if you hide a semitransparent element and then display it, its transparency settings are restored.

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.