conware
09-25-2011, 02:59 PM
Hi guys,
I need some help. Im trying to make a navagation menu with images that need to be changed when someone hovers over the child category.
So lets say I have a menu that looks like this:
<img src="notactiveimagemenu1.jpg" alt="">
<ul id="menu1">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
<img src="notactiveimagemenu2.jpg" alt="">
<ul id="menu2">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
Now what im trying to do is if someone hovers over the li items from menu1 to change the image src of menu1.jpg to active.
I was hoping to do this with some javascript.
// i was thinking about something like this:
// first put menu items in a array
// then use document.getElementById(id).onmouseover = function()
// and make some sort of check to see which src should be changed.
Now I really have no clue how to do it.
So if anyone knows a cool solution please let me know.
I know I could add onmouseover events to each li item and changing the src of the category. But Im trying to find a better solution.
And I think I should be able to use document.getElementById(id).onmouseover = function() for that.
Anyway thanks for any tips.
Please note I know I could use jquery to do all of this very easy but I consider this practice because I don't know that much javascript.
I need some help. Im trying to make a navagation menu with images that need to be changed when someone hovers over the child category.
So lets say I have a menu that looks like this:
<img src="notactiveimagemenu1.jpg" alt="">
<ul id="menu1">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
<img src="notactiveimagemenu2.jpg" alt="">
<ul id="menu2">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
Now what im trying to do is if someone hovers over the li items from menu1 to change the image src of menu1.jpg to active.
I was hoping to do this with some javascript.
// i was thinking about something like this:
// first put menu items in a array
// then use document.getElementById(id).onmouseover = function()
// and make some sort of check to see which src should be changed.
Now I really have no clue how to do it.
So if anyone knows a cool solution please let me know.
I know I could add onmouseover events to each li item and changing the src of the category. But Im trying to find a better solution.
And I think I should be able to use document.getElementById(id).onmouseover = function() for that.
Anyway thanks for any tips.
Please note I know I could use jquery to do all of this very easy but I consider this practice because I don't know that much javascript.