Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery "this" plus other selectors?

Tags:

jquery

hover

Is it possible to combine $(this) with $('.someclass')?

Example: $(this + ', .someclass').hover();

I am attempting to use the hover action to animate a non-descendent class. I want the class element to animate whether "it", aka $('.someclass') OR $(this) is hovered.

I'm hoping this can be done without creating 2 separate hover actions.

like image 678
Ryan Prentiss Avatar asked Dec 30 '11 17:12

Ryan Prentiss


People also ask

Can we use multiple selectors in jQuery?

jQuery - Multiple Elements SelectorYou can specify any number of selectors to combine into a single result.


1 Answers

You can use jQuery's .add().

$(this).add('.someClass').hover();
like image 162
Rocket Hazmat Avatar answered Sep 26 '22 01:09

Rocket Hazmat