jQuery hover function -
hi trying create jquery function fades other divs when 1 of div clicked on. code isn't working , i'm not sure how write it. here have far:
$("#slider div.popup").hover( var ind = $(this).index(); $("#slider div.popup").each(function() { if ($(this).index() != ind) { //fades other .popup divs $(this).animate({ opacity: 0 }); } }), $("#slider div.popup").each(function() { if ($(this).index() != ind) { //unfades other .popup divs $('span', this).animate({ opacity: 1 }); } } )); there example here : http://jsfiddle.net/7j3mk/
can give me guidance on how code working?
beside wrong syntax use hover method (it takes 2 functions parameters) need use .not() docs method
$("#slider div.popup").hover( function(){ $("#slider div.popup").not(this).stop().animate({ opacity: 0 }); }, function(){ $("#slider div.popup").not(this).stop().animate({ opacity: 1 }); }); updated example @ http://jsfiddle.net/gaby/7j3mk/11/
Comments
Post a Comment