Jump to content

Javascript hover (navigation)


Callum

Recommended Posts

I would appreicate some help with this, its probably dead easy :) Here is the code I used for 1 of the navigation buttons to change the image when you hover (taken off the w3 schools javascript animation). It works fine for one button, however I can't make it work for multiple buttons in my navigation section. I was wondering could anybody show me how to modify / build on the existing code / javascript to make it work for a total of 6 buttons in my navigation. Also the images I'm using are the same for all 6 buttons. I'd prefer a simple method modifying the existing code rather than starting some crazy new code as I'm a complete newbie to javascript.Thanks for your helpCallum

<script type="text/javascript">function mouseOver(){document.b1.src ="buttonh.jpg";}function mouseOut(){document.b1.src ="button.jpg";}</script><div class="button1"><a href="hometestj.htm"><img border="0" alt="home" src="button.jpg" name="b1" width="100"onmouseOver="mouseOver()"onmouseOut="mouseOut()" /></a></div>

Link to comment
Share on other sites

If by a "simple" mod you mean real simple, it can't be done. You need a lot of tweaking here. That code is more for instruction than actual use. Better to google the concept and get some more functional code.Best yet, google rollover and CSS instead of javascript. You can get the same effect in far fewer lines.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...