I am trying to target the background of my navigation and 4 other divs in the body copy when mousing over any navigation links or the divs in the body copy.
- when mousing over any one of the four divs in the body copy the other three divs should fade and the navigation divs backgroun dcolor should change as well
i have it working but i am new to javascript/jquery and i know there is a better way to do it.
What would that be?
link to dev site is http://www.alienfactory.com/vision1/
Its kinda funny everytime i look at it it looks like i am trying to write javascript like it is CSS
here is a code snippet it repeats 3 more time for the various mouseover targets
$('#services, #navservices').hover( function () { $('#vision, #approach, #team').stop().fadeTo('slow', .2); $('#navigation').stop().animate({ backgroundColor: "#8ac2b7" }, 500); }, function () { $('#vision, #approach, #team').stop().fadeTo('slow', 1); $('#navigation').stop().animate({ backgroundColor: "#404040" }, 500); } );
for further clarification here is the full script. I know there is a better way but how?
$('#services, #navservices').hover( function () { $('#vision, #approach, #team').stop().fadeTo('slow', .2); $('#navigation').stop().animate({ backgroundColor: "#8ac2b7" }, 500); }, function () { $('#vision, #approach, #team').stop().fadeTo('slow', 1); $('#navigation').stop().animate({ backgroundColor: "#404040" }, 500); } ); $('#vision, #navvision').hover( function () { $('#services, #approach, #team').stop().fadeTo('slow', .2); $('#navigation').stop().animate({ backgroundColor: "#9e97ca" }, 500); }, function () { $('#services, #approach, #team').stop().fadeTo('slow', 1); $('#navigation').stop().animate({ backgroundColor: "#404040" }, 500); } ); $('#approach, #navapproach').hover( function () { $('#services, #vision, #team').stop().fadeTo('slow', .2); $('#navigation').stop().animate({ backgroundColor: "#e5b120" }, 500); }, function () { $('#services, #vision, #team').stop().fadeTo('slow', 1); $('#navigation').stop().animate({ backgroundColor: "#404040" }, 500); } ); $('#team, #navteam').hover( function () { $('#services, #vision, #approach').stop().fadeTo('slow', .2); $('#navigation').stop().animate({ backgroundColor: "#cf1858" }, 500); }, function () { $('#services, #vision, #approach').stop().fadeTo('slow', 1); $('#navigation').stop().animate({ backgroundColor: "#404040" }, 500); } );