FadeIn vs fadeOut vs fadeTo

What is the difference between fadeInvs fadeOutvs fadeTo?

+5
source share
4 answers

fadeIndies from the current opacity of the elements to 1.
fadeOutdies from the current opacity of the elements to 0.
fadeTodies from the current opacity of the elements to the specified opacity.

$('#myObject').fadeTo('fast', 0.5, function() {
    $('#myObject').fadeTo('fast', 0.8);
});

The aforementioned fades myObjectfrom any opacity it has to 0.5, which is 50% transparency, and after that it disappears again to 20% transparency.

+11
source

Short answer:

  • fadeIn() fadeOut() display fade.
  • fadeTo() opacity fade.

:

fadeIn() fadeOut() display, show() hide(), .

fadeIn()

  • : opacity:0.
  • : display:block.
  • : opacity:1.

fadeOut()

  • : opacity:0.
  • : display:none.

fadeTo() opacity .

fadeTo()

  • : display: block.
  • : opacity: [$].

. , fadeIn() fadeTo() JsFiddle.

Update:

fadeIn() fadeOut() show() hide().

show() hide() display, fadeIn() fadeOut(), , , aimate .

show()

  • : opacity:0, width:0, height:0
  • : display:block
  • : opacity:1, width:[auto], height:[auto]

hide()

  • : opacity:0, width:0, height:0
  • : display:none.

:

fadeIn(), fadeOut(), fadeTo(), show() hide() JsFiddle.

+10

FadeIn..

FadeOut..

FadeTo..

+2

Here I see only linguistic redundancy, since fadeTo is suitable for all use cases independently.

0
source

All Articles