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 4 of 4
  1. #1
    Junior Member djsquid's Avatar
    Join Date
    Aug 2011
    Location
    Staffordshire
    Posts
    15
    Member #
    28854
    Hi guys,

    I'm working on a website for a summer project, and I've kind of gone to town with the navigation menu, for example, I have 'Categories' which opens up a sub menu with 'Fashion, Motors, Property, Services', and then from this sub menu we have another sub menu such as clicking 'Fashion' opens 'Mens, Women's, Children's,Pets'.

    Basically what I am trying to do is instead of having loads of separate pages for my categories I am using multiple Content divs for each one, what I have done so far though is create my homepage and 2 other divs 'Mens Smart' and 'Mens casual' which I have set the overflow to 'scroll' so they are all nicely within the content div.

    My question been how can I make these divs fade in and out from clicking on the Anchor tag within the Navigation Menu?

    I did some trial and error earlier with the;

    $('.mensmart').click(function() {
    $('.mensmartfashion').fadeToggle(500);
    return false;
    });

    .mensmart = anchor class name
    .mensmartfashion = div name

    but this didn't seem to work, Do I need to do something special to the CSS & Javascript so they fade in on top of each other? obviously they will all be hidden via Jquery, but faded in when clicked on the anchor, and faded out via a button in each div so the homepage can fade back in....

    Hope I've made sense, I am new to all of this by the way, I have only been learning HTML, CSS and Jquery for the past week...

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Here's what I did that I think does what you're wanting:
    I'll do this example for 2 divs, but I did it for 5 with no problem. I'm going to use link-1, link-2, div-1 & div-2 to make it easier to follow.

    Make sure the div you want to show when the page initially loads is visible, but set the other(s) to display:none in your CSS.

    Then, the jQuery:
    Code:
    $(function(){
       $('link-1').click(function(){
          $('div-1').fadeIn(500);
          $('div-2').hide();
       });
    });
    $(function(){
       $('link-2').click(function(){
          $('div-2').fadeIn(500);
          $('div-1').hide();
       });
    });
    You'll have to forgive me if there are syntax mistakes or if it's more complicated than necessary; I'm still pretty new at jQuery/JavaScript. Anyway, that worked quite well for me.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Junior Member djsquid's Avatar
    Join Date
    Aug 2011
    Location
    Staffordshire
    Posts
    15
    Member #
    28854
    Hey Ronald, that worked perfectly, thank you very much for that! exactly what I need! I need to do this for 61 divs!

  5. #4
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    That's a lot of divs. Hopefully someone can give you an easier way.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


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
  •  

Search tags for this page

fadein fadeout anchor link

Click on a term to search for related topics.
All times are GMT -6. The time now is 05:27 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com