Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    7
    Member #
    32383
    I'm trying to make a search bar fade in after checking whether the contents (#list) of a fade toggle button (#listContainer a) is hidden (by display:none). When the toggle button (#listContainer a) is pressed it fades in its content (#list) which is hidden (by display:none) and the search bar fades out. When you press the toggle button again, it fades out its content and the search bar fades back in.

    Here is the code for the search bar to fade out if the fade toogle button (#listContainer a) is hidden (due to the toogle fade out effect).

    $(document).ready(function()
    {
    if($('#list').is(':visible'))
    {
    $("#search form").fadeIn(100);
    }
    });

    This is the code for the fade toggle button (#listContainer a), which fades out the search bar (#search form) when it's clicked on.

    $(document).ready(function()
    {
    $("#listContainer a").click(function()
    {
    $("#list").fadeToggle(400);
    $("#search form").fadeOut(100);

    });
    });

    As of now this code isn't working for me and I don't know why. When I try to fade in the search bar by pressing a button, it fades in fine after being faded out by the fade toggle button.

  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Since I'm assuming you're using jquery for the actual fade effect, are you sure the jquery library is loading properly ?

    Try the chrome browser "inspect element", to see if there are any errors .

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,480
    Member #
    425
    Liked
    2784 times
    You can chain the events together. I'm not sure if this is what you want, but something like this would get you there:
    Code:
    $("#listContainer a").click(function() 
    { 
    $("#list").css("display", "block").fadeToggle(400, function () {
    $("#search form").fadeToggle(400);
    });
    });
    However, a fade won't work if your list element is set to display: none; since the list will never be displayed. Hence, the CSS for display: block.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:21 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com