Results 1 to 2 of 2

Thread: Can't add .fadeIn effect (jQuery)

  1. #1
    Join Date
    Jan 2007
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Can't add .fadeIn effect (jQuery)

    Any jQuery experts here?

    Code:
    if(msg == "OK")
    {
    result = '<img src="/images/sent.png"><br />Your message has been sent';
    
    $("#fields").hide();
    $(this).html(result);
    
    }
    I spent several hours trying to add .fadeIn effect to the result so that result doesn't appear immediately, but fades in. No success. Can somebody help?
    Last edited by jscheuer1; 09-27-2009 at 04:12 PM. Reason: proper format for code

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, according to the jQuery documentation page on this effect:

    http://docs.jquery.com/Effects/fadeIn

    it can be deduced that the thing you are fading in should be hidden (display: none;). Assuming from your code that 'this' refers to the element that contains the result, make it display none first. Then you can (addition highlighted):

    Code:
    $(this).html(result).fadeIn('slow');
    or to do all three things at once:

    Code:
    $(this).css('display', 'none').html(result).fadeIn('slow');
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •