tags:

views:

116

answers:

3

I've got this test page going on: http://joshuacody.net/qworky/

Warning: Tons of CSS3. This will only look right in Safari or Chrome. Firefox will be tolerable. All else will be lost.

Essentially, when I hover on someone's name, I'd like it to trigger the hover state on their image as well. It's working now, but I feel the solution is inelegant. I'd rather not add more classes. Here it is:

$('a.name_link').hover(function(){
    $(this).parent('p').siblings('img').toggleClass('link_hover');
});

$('img.name_img').hover(function(){
    $(this).siblings('p').children('a').toggleClass('hover');
});

I thought the following would work:

$('a.name_link').hover(function(){
    $(this).parent('p').siblings('img').trigger('hover');
});

Any idea why it's not? I'm really looking for the cleanest, simplest way to do this. Thanks so much!

A: 
iangraham
Hey iangraham, I should have mentioned, I've tried 'mouseover' and 'mouseenter', still with no luck. Also, I've been able to retrieve the 'src' and 'href' of the elements in questions via console.log
Joshua Cody
A: 

Instead of just one function, the hover function is supposed to have 2 functions. Try putting both functions on there.

jeffkee
Hey Jeffkee, I appreciate it, but the second function is optional. So that wouldn't be the issue.
Joshua Cody
A: 

Turns out I could just rework my CSS to do that, putting the img inside of the anchor tag.

Joshua Cody