Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2011, 09:22 PM   PM User | #1
gribbs100
Regular Coder

 
Join Date: Feb 2006
Posts: 168
Thanks: 32
Thanked 1 Time in 1 Post
gribbs100 is an unknown quantity at this point
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
gribbs100 is offline   Reply With Quote
Old 05-19-2011, 10:42 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
$(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.
devnull69 is offline   Reply With Quote
Old 05-20-2011, 12:32 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 05-20-2011, 01:23 AM   PM User | #4
gribbs100
Regular Coder

 
Join Date: Feb 2006
Posts: 168
Thanks: 32
Thanked 1 Time in 1 Post
gribbs100 is an unknown quantity at this point
Thanks guys for that info. Ill give it a try. Ill report back if it doesn't work.

Thanks again.
gribbs100 is offline   Reply With Quote
Reply

Bookmarks

Tags
fadeout, function, jquery, url

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:12 PM.


Advertisement
Log in to turn off these ads.