SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .fadeIn() and .FadeOut() VS .animate({opacity: '0'}) and .animate({opacity: '1'})??

    I've noticed some people use .fadeIn() and .FadeOut() and then I noticed some using .animate({opacity: '0'}) and .animate({opacity: '1'}) .. is there a difference or a reason to pick one over the other?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,700
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by enwise View Post
    I've noticed some people use .fadeIn() and .FadeOut() and then I noticed some using .animate({opacity: '0'}) and .animate({opacity: '1'}) .. is there a difference or a reason to pick one over the other?
    There really is no signficant different between them, other than how the code is presented.

    The jQuery code for fadeIn and fadeOut is:

    Code:
    fadeIn: { opacity: "show" },
    fadeOut: { opacity: "hide" },
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    There really is no signficant different between them, other than how the code is presented.

    The jQuery code for fadeIn and fadeOut is:

    Code:
    fadeIn: { opacity: "show" },
    fadeOut: { opacity: "hide" },
    is there ever a time to use 1 over the other?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,700
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by enwise View Post
    is there ever a time to use 1 over the other?
    Normally you would use fadeIn and fadeOut.
    You would use the more explicit numeric version if you are using a variable to customize the level of opacity of an object.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thank u !


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •