treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] help with some jquery

  • I am trying to figure out how to get the background of the hovered anchor tag to turn the span.number background red. Right now when I hover, it turns them all red. I only want the one that is hovered on red. So if you hover on a category, it will turn the category color red as well as the background of the number to the right red.

    http://jsfiddle.net/fPj52/3/
  • Maybe list each one as an individual class and call the class?

    $(#span).onMouseOver(function(){
    $(#span.number.one).css('red');
    });
  • that didn't work
  • First off: your markup is wrong, more specifically the nesting:

    <li><span class="category"><a href="#">Movies</span><span class="number">10</span></a></li>
    You close the first span, while the anchor is still open. I believe you want this:

    <li><a href="#"><span class="category">Movies</span><span class="number">10</span></a></li>
    Also, I don't really see the point of putting each line in a separate UL and then have two LI's in there. I think you'd be better off with one UL, with 4 LIs that each contain two spans, but anyway, that's not what this issue is about.

    Here's something that you should be able to use: http://jsfiddle.net/fPj52/27/
  • My multiple ul's made more sense in an earlier version of my code. Now I see that it does make more sense to get rid of them and have just the one.

    Thanks for the code. That is what I was trying to accomplish