Jump to content

JQuery fadeIn problem


son.of.the.morning

Recommended Posts

Hey guys, i was wondering if you could help me with a little JQuery problem?

 

I have a list menu with a sub menu and i want to create a condision were when the sub menu changes to a vissible display i want it to fadeIn using Jquery rather than it just apearing.

 

Any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/251338-jquery-fadein-problem/
Share on other sites

Sorry i forgot to add the code i have been working on. The code is valid but because the display is set to 'non' initially then it doesn’t take effect, so i need a condition that’s going to say if the display = to block (visible) then fadeIn.

 

$(document).ready(function() {
	$('.SubFade').hover(function() {
		var div = $('.subMenu, this');
		div.fadeIn(2500);	
	});

    });

I have tryied to use toggle() here but it works funny if i rollover the first time the menu fades in but if i then rollover it again the views normal then fades out. I really need it to fade out on hover and when the cursor leaves the sub menu i want it to fade out. This one is realy doing my nut in right now!

 

	$(document).ready(function(){
	$('.SubFade').hover(function(){
		$('.subMenuContainer').toggle(2000);
	});
});

hover() accepts two call backs, one for mouseover and one for mouseout. You need to call the toggle function in each:

 

	$(document).ready(function(){
	$('.SubFade').hover(function(){
		$('.subMenuContainer').toggle(2000);
	}, function() {
		$('.subMenuContainer').toggle(2000);
	});
});

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.