1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[jQuery] How can I hide page elements after the opacity animation?

Discussion in 'HTML & Website Design' started by kent55, Dec 25, 2013.

  1. #1
    Hi,

    I am making a website for myself and the only part I am not confident in is JavaScript. This jQuery code is the navigation and what makes each page fade out then fade in with opacity. Now the issue I am having is that when I add links because the actual content isn't hidden you can still click the links on other pages. So what I am asking is: What edit can be made to this code to keep the opacity animation but hide the content too?

    Code:

    Code (Text):
    1. jQuery(document).ready(function() {
    2.  
    3.     /* How to Handle Hashtags */
    4.     jQuery(window).hashchange(function(){
    5.         var hash = location.hash;
    6.         jQuery('a[href='+hash+']').trigger('click');
    7.     });
    8.  
    9.     /* Main Navigation Clicks */
    10.     jQuery('.main-nav ul li a').click(function() {
    11.         var link = jQuery(this).attr('href').substr(1);
    12.        
    13.         if ( !jQuery('section.content.show, section#' + link).is(':animated') ) {
    14.             jQuery('.main-nav ul li a').removeClass('active'); //remove active
    15.             jQuery('section.content.show').addClass('show').animate({'opacity' : 0}, {queue: false, duration: 1000,
    16.                 complete: function() {
    17.                     jQuery('a[href="#'+link+'"]').addClass('active'); // add active
    18.                     jQuery('section#' + link).addClass('show').animate({'opacity' : 1}, {queue: false, duration: 1000});  
    19.                 }
    20.             });
    21.         }
    22.     });
    23.  
    24. });
    Thanks in advance.
    kent55, Dec 25, 2013 IP