Changing the child element's CSS when the parent is hovered

The Solution to Changing the child element's CSS when the parent is hovered is


Why not just use CSS?

.parent:hover .child, .parent.hover .child { display: block; }

and then add JS for IE6 (inside a conditional comment for instance) which doesn't support :hover properly:

jQuery('.parent').hover(function () {
    jQuery(this).addClass('hover');
}, function () {
    jQuery(this).removeClass('hover');
});

Here's a quick example: Fiddle

~ Answered on 2011-02-21 03:25:10


Most Viewed Questions: