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/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;
}
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
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.
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
squaredWeb said
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!
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?
Oops, that last post is from me. Forgot I was logged into another account
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.
