Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    168
    Thanks
    32
    Thanked 1 Time in 1 Post

    This jquery I've written wont fade out div before going to url

    Hello Guys, I am kind of new to this language but i had this working at one point and now it doesn't work correctly. When you click the link in the footer div, it should fade out the home_main div and then after completed, proceed to the link url.

    The issue is that when you click, it is skipping the fadeOut and just going to the url like a normal hyperlink.

    the div is set to display none in the css by default so that isn't the problem. I think i just have a scripting mistake:

    Code:
    $('#footer a').click(function(){
    
    	
    $('.home_main').delay(200).fadeOut(500,function(){	
    	
    var newLocation = $(this).attr('href');
    		document.location = newLocation;
    	
    });
    	
    	return false;
    
    });
    Any ideas what I did wrong? the rest of my jquery is working fine but not this segment

    Thanks

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    $(this).attr('href') might be undefined. $(this) doesn't refer to the clicked object but to .home_main. I think it will just produce an error and render the code useless.

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Yeah, move the “var newLocation” line one level up, right into the click function (i. e. to the second line of your posted script) and see if that works.

  • #4
    Regular Coder
    Join Date
    Feb 2006
    Posts
    168
    Thanks
    32
    Thanked 1 Time in 1 Post
    Thanks guys for that info. Ill give it a try. Ill report back if it doesn't work.

    Thanks again.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •