Simple jQuery rollover killin me !!

I have a simple rollover that I can't seem to get right.
I need to change the background image of a child object.

here's the html/php:
<div id="menuBoxContent" alt="navigation">
						//get list of available icons from database
							if($i%8==0){ echo "<div id=\"menuOptionRow\">"; }
					?>  <div id="menuOption" alt="parent">
								<div id="menuOptionIcon" alt="icon"></div>
								<div id="menuOptionTitle"><?php echo $iconTitle;?></div>
					<?php if($i%8==0){ echo "</div>"; }} ?>

Open in new window

here's the jQuery:
<script type="text/javascript">

//Menuoption rollover


Open in new window

I have to use the $(this) selector bc there could be many iterations of the div 'menuOption'.

When someone rolls over the div 'menuOption', I need to change the background image of the child object 'menuOptionIcon'

I just cant seem to figure out the proper use of the .children() method ..

TIA Experts !!
Who is Participating?
I have to use the $(this) selector bc there could be many iterations of the div 'menuOption'.
you should avoid to pass an id to more than one DOM Element in your HTML, pass a class instead.

The proper way to use the children method is like this:

But like this you are calling the children of the menuOptionIcon Element. What you want to do is to call the children of the menuOption Element, so try like this:
$("#menuOptionIcon", this).css('background-image','url("images/icons/txtRest50.on.png")');

Hope this could help.
why not doing it with CSS

div#menuOption:hover #menuOptionIcon{background-image:#999;url("images/icons/txtRest50.on.png")}

Open in new window

ImaginxAuthor Commented:
Perfect solution Mcnute ... Thanks .. I'm still new to jQuery - but I understand your solution.
Thank you for the great explanation.

Merry Christmas btw !!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.