jquery - Fade in/out the hover for gallery box -
hello , sorry asking simple things! jquery noob , tough researched lot did not manage make simple effect work.
i want child faded in on parent hover , fade out on mouseout.
my other problem divs have same class , if show/hide childrens on hover effect applies other divs , bad... need way make jquery understand wich element hovered tough of them have same class.
i not sure how explained made quick jsfiddle: http://jsfiddle.net/6nbbz/
and here jquery:
$(".container").mouseover(function() { $("a").fadein("slow"); }); $(".container").mouseout(function() { $("a").fadeout(); });
thanks!
you need study jquery's dom traversal methods, these in kind of situations need find elements relative other elments, in case want use find()
select descendants of hovered element.
also, instead of mouseover
should use mouseenter
handle hover event code runs once when mouse enters element, prefer use hover()
2 function arguments handle mouseenter
, mouseleave
respectively:
$(".container").hover(function() { $(this).find("a").stop().fadein("slow"); },function(){ $(this).find("a").stop().fadeout(); });
also note need remove css rule , let jquery handle display of elements
Comments
Post a Comment