SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery: fadeIn problem

    Hello there x)

    I'm new in this forum & in jQuery's world!
    Before starting, I'd like to apoligize for my english, it's not my native language.

    My knowledges in html/css are good, but i'm a novice in Javascript (but I already played with lightboxes using jQuery, modifying values and trying to make it fits to my websites).

    Well, I received today the book "Novice to Ninja - jQuery" and I arrived to the page 60. That's... an amazing and passionnate book, I readed and practised 6 hours in a row, and I can't even sleep until I find why the fadeIn function doesn't work while the fadeOut is working o.O I tried it on buttons, to hide/show selections, it worked. But it doesn't when I apply it to a div or a paragraph :/

    Here is my source code:
    $(document).ready(function(){
    $('#test').fadeIn(3000);
    });

    And in the HTML page:
    <p id="test">Welcome to StarTrackr! the planet's premier celebrity tracking and monitoring service. Need to know where in the world the best bands, musicians or producers are within 2.2 square meters? You've come to the right place. We have a very special special on B-grade celebs this week, so hurry in!</p>
    If I replace fadeIn by fadeOut, it works: my paragraph goes from black to hided.
    So... what's the prob? :S

    Thanks in advance!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    The fadeIn method find that the element is already fully visible, so it has nothing that needs to be done.

    Shouldn't the element first be hidden, so that the fadeIn method has something that can be faded in?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you! It solved my problem!

    New code:
    $(document).ready(function(){
    $('#test').hide();
    $('#test').fadeIn(3000);
    });


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
  •