751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

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/
32 posts
  • Bought between 50 and 99 items
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 50 000 and 100 000 dollars
synesthete says

Hi, if You want change only background color use css only:

ul li:hover span.number {
background-color:red;
}

or

ul:hover span.number {
background-color:red;
}
751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

yes, that will work but it will not work if you hover over the span.category. That is why I am trying to use jquery

301 posts
  • Austria
  • Exclusive Author
  • Has been a member for 3-4 years
  • Microlancer Beta Tester
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
squaredWeb says

Here you go: http://jsfiddle.net/fPj52/10/

I moved the “category” class from the span to the li and since i have no clue if the span is used for something more later i just left it in.

4128 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says

Here you go: http://jsfiddle.net/fPj52/10/ I moved the “category” class from the span to the li and since i have no clue if the span is used for something more later i just left it in.

+1. Would’ve done the same!

no-thumbnail
caliperconstruction Recent Posts
Threads Started
1 post
  • Bought between 1 and 9 items
  • Has been a member for 2-3 years
caliperconstruction says

Thank you. Very interesting. Just out of curiosity, why bother moving the category class form the span to the li? is there really a difference?

751 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • United States
CyberShot says

Oops, that last post is from me. Forgot I was logged into another account

301 posts
  • Austria
  • Exclusive Author
  • Has been a member for 3-4 years
  • Microlancer Beta Tester
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
squaredWeb says

Basically its just the shortest and most efficient way, at least to my knowledge, to achieve this effect. If you use ”$(this)” on the span with the “category” class you would have to go the extra mile with something like this: http://jsfiddle.net/fPj52/25/

Plus if you move the class to the li element you can remove the span and save some html markup.

by
by
by
by
by
by